Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 1st, 2005, 08:22 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
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

  #2 (permalink)  
Old December 3rd, 2005, 11:03 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
  #3 (permalink)  
Old December 4th, 2005, 04:48 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
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;
        }
    }


  #4 (permalink)  
Old December 6th, 2005, 03:12 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:57 PM.


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