473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with making a control work . Please help :-(

Hi everyone,

I'm having a problem with getting a control that I'm using to work.

I have a placeholder control sitting within a user control.

On certain occasions at runtime I create a Textbox control and add it to the
placeholder. This works well almost all the time.

Unfortunately there is one scenario when it doesnt work. The textbox doesnt
seem to be initialised whereas it normally is.

Does anyone know why it should work sometimes but not others?

I think its something to do with me needing to initialise the Textbox
control myself. Could someone show me how to do that and where to put the
code? I've tried just creating a new textbox, setting its Text and then
adding it to the pages control collection. This just ends up adding a new
textbox to the form :-(

If anyone could help with this I would be very greatful. I've heard lots of
people saying that you need to initialise your user controls manually but iv
never seen a decent example of where and how to do it.

Thanks

Simon
Nov 18 '05 #1
2 1036
q
Could you post your code for creating the TextBox
& code for your Page_Load?

Simon Harvey wrote:
Hi everyone,

I'm having a problem with getting a control that I'm using to work.

I have a placeholder control sitting within a user control.

On certain occasions at runtime I create a Textbox control and add it to the
placeholder. This works well almost all the time.

Unfortunately there is one scenario when it doesnt work. The textbox doesnt
seem to be initialised whereas it normally is.

Does anyone know why it should work sometimes but not others?

I think its something to do with me needing to initialise the Textbox
control myself. Could someone show me how to do that and where to put the
code? I've tried just creating a new textbox, setting its Text and then
adding it to the pages control collection. This just ends up adding a new
textbox to the form :-(

If anyone could help with this I would be very greatful. I've heard lots of
people saying that you need to initialise your user controls manually but iv
never seen a decent example of where and how to do it.

Thanks

Simon


Nov 18 '05 #2
Ok, thanks for your reply.

If the textbox should be displayed, as determined on the first request to
the page - I make a control and add it to the placeholder:

txtUsername = new TextBox();
txtUsername.ID = "txtUsername";
txtUsername.BorderWidth = 1;
txtUsername.BorderStyle = BorderStyle.Solid;
phUsernamePlaceholder.Controls.Add(txtUsername);

Later, if the situation is a postback I have:

txtUsername = new TextBox();
txtUsername.ID = "txtUsername";
txtUsername.BorderStyle = BorderStyle.Solid;
txtUsername.BorderWidth = new Unit(1);
txtUsername.Text = Request.Form["createUserControl:txtUsername"];

This now seems to be working but I'm not 100% sure why. Is this normally
what you have to do with controls? Seems quite simple. You don't have to do
anything special - just create a new txt box and make sure it has the same
name as the one that should be on the page?

Thanks

Simon
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
by: Jesper Denmark | last post by:
Within the following construction switch (expression) { int i; i = GetArgs() //return 2 case constant-expression:
1
by: Shawn B. | last post by:
Greetings, I have have been working for almost 18 months on a set of WebControls where some are similar to the ASP.NET standard and well-enhanced while other controls are completely new and...
13
by: Lloyd Sheen | last post by:
I have now spent 5 hours on google/msdn looking for something useful in the creation of user controls for asp.net. The VS 2003 has very limited support for things such as absolute positioning of...
0
by: MattB | last post by:
I fixed my "can't get the textbox.text" issue by making sure I was only binding the repeater on the first load of the page (if Not IsPostBack). Now I'm adding other controls to my repeater and am...
4
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO...
0
by: Walter | last post by:
Hi, can someone please help me with my custom control viewstate problem....I haven't slept for hours trying to get this fixed. I am making two custom controls which will be included on a single...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.