Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Simon Harvey #1
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
Simon Harvey Guest
-
making pop-ups work
Hi, I'm scripting buttons in Flash MX to open HTML pop-up windows . I found the download example in the tutorials sections on how to script... -
CSS - Making content margins work for me
Hello. I'm building a page that should fill the width of my browser window, with 3 pixels of space at the top, left, and right. If I use a... -
making XML::Parser work?
I have downloaded and installed latest Expat. I have downloaded Expat.pm (and yeah if ou saw my post in .misc, I re-downloaded and it solved the... -
help with making media components work with flv
I built a project in MX 6.0 that I published in a projector and burned to CD. It contained a number of swfs with embedded video clips which the user... -
Making a response form work
Hi - I have inserted a form on my web site and configured it to send responses to my email address. But it doesn't work !!! When the submit... -
q@q.com #2
Re: Help with making a control work . Please help :-(
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
>
>
>q@q.com Guest
-
Simon Harvey #3
Re: Help with making a control work . Please help :-(
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
Simon Harvey Guest



Reply With Quote

