allanmark
asked on
Controls created in Source view do not show up under intellisense
Greetings all
I have just completed the setting up of a page, done in source view, and using some CSS.
I switched to code-behind to begin with my coding but noticed that many of the controls, particualrly buttons and textboxes) were not showing up under inyellisense.
Is there perhaps something that I need to do before this will work?
In advance, thanks!
allanmark
I have just completed the setting up of a page, done in source view, and using some CSS.
I switched to code-behind to begin with my coding but noticed that many of the controls, particualrly buttons and textboxes) were not showing up under inyellisense.
Is there perhaps something that I need to do before this will work?
In advance, thanks!
allanmark
I think the problem is that all your controls are inside templated controls. To access these controls from code you'd need to use the findcontrol method of the templated control they are inside, you can't access directly from your code, hence they don't show up in intellisense.
For example to access the UserName textbox inside logMember you'd write something like:
TextBox tb = (TextBox) logMember.FindControl("Use rName");
The variable tb then references the textbox you want and you can access it's properties using this.
For example to access the UserName textbox inside logMember you'd write something like:
TextBox tb = (TextBox) logMember.FindControl("Use
The variable tb then references the textbox you want and you can access it's properties using this.
ASKER
Thanks 4 the quick response!
I suppose my question, before I go further, should be: is the way I have done this page Ok? Or is it bad? Do I need to redo it?
If the page passes, then I need to do a FindControl for each field, since I will be using all of them. Woudl it be acceptable to call a routine from my pageLoad (see snippet) or is teher a better way?
I suppose my question, before I go further, should be: is the way I have done this page Ok? Or is it bad? Do I need to redo it?
If the page passes, then I need to do a FindControl for each field, since I will be using all of them. Woudl it be acceptable to call a routine from my pageLoad (see snippet) or is teher a better way?
protected void Page_Load(object sender, EventArgs e)
{
...............
CreateAccessibles()
}
protected void CreateACcessibles()
{
TextBox tbUser = (TextBox) logMember.FindControl("UserName");
TextBox tbName = (TextBox) logMember.FindControl("txtName");
TextBox tbSurname = (TextBox) logMember.FindControl("txtSrname");
............
.............
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks!!!
ASKER
Open in new window