Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2005, 08:22 PM
Registered User
 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom control location

I try the custom control in the sample code for the book Professional C# 2nd edition. No matter where do you put the custom control on the webform, when you start the webform, the control always appear on the up-left corner.

My question is, how do you pass the location in the visual studio designer to the custom control at the run-time?

Thank you very much for help.

Junshi

 
Old December 3rd, 2005, 11:03 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This sounds like a problem with the forms layout. If it's using grid layout then the positions need to be exact. Also, if your custom control is writing out explicit positioning information in it's rendered HTML then that could be causing the problem. Post the browsers page source HTML if you still can't find the problem.

-Peter
 
Old December 4th, 2005, 04:48 PM
Registered User
 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Peter,

Here is a web custom control. Please the control anywhre on a webform. When you run the page, the control is always on the up-left corner.

Thank you for your help.

Jerry

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing;

namespace PCSCustomWebControls
{
    public class RainbowLabel : System.Web.UI.WebControls.Label
    {
        private Color[] colors = new Color[] {Color.Red, Color.Orange,
                                                 Color.Yellow, Color.GreenYellow,
                                                 Color.Blue, Color.Indigo,
                                                 Color.Violet};

        private int offset
        {
            get
            {
                object rawOffset = ViewState["_offset"];
                if (rawOffset != null)
                {
                    return (int)rawOffset;
                }
                else
                {
                    ViewState["_offset"] = 0;
                    return 0;
                }
            }
            set
            {
                ViewState["_offset"] = value;
            }
        }


        protected override void Render(HtmlTextWriter output)
        {
            string text = Text;

            for (int pos=0; pos < text.Length; pos++)
            {
                int rgb = colors[(pos + offset) % colors.Length].ToArgb() & 0xFFFFFF;
                output.Write(""
                    + text[pos] + "");
            }
        }

        public void Cycle()
        {
            offset = ++offset;
        }
    }


 
Old December 6th, 2005, 03:12 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What about the form this lives on? If that is set to grid layout that could be what's causing the problem. Otherwise, I don't know. You aren't writing out any other HTML that should result in explicit positioning.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Server Control....Custom Property Editor ZArrinPour ASP.NET 1.0 and 1.1 Basics 1 June 15th, 2010 11:30 AM
Web Service, Custom Control, Custom Return Type robzyc ASP.NET 2.0 Basics 6 June 10th, 2008 08:03 AM
custom control inside custom control issues StevesonD ASP.NET 2.0 Professional 1 February 19th, 2008 06:54 PM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM
Change TextBox control location on aspx page minhpx General .NET 2 March 4th, 2005 08:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.