-
December 13th, 2011, 01:53 PM
#1
Find ASP element by ID
Hello,
I have a MasterPage with a content place holder:
PHP Code:
<asp:ContentPlaceHolder id="MainContenedor" runat="server"> </asp:ContentPlaceHolder>
I am working in the Child page. I can access any element by typing:
PHP Code:
Me.ControlName.atributes
My problem comes when I want to access that control by finding it because I have a dynamic ASP element list.
Next line throws an error of NullReferenceException
PHP Code:
Me.FindControl("chkStatus_1").ID
I have also tried with the extra parameter
PHP Code:
Me.FindControl("chkStatus_1",1).ID
From 0 to 11 levels (-1 and 12 are out of range)
I don’t know what else to try except recursively access from child to the masterpage and from there to the child container…. But that seems a little weird soluion.
Hope anyone can help me with this.
Thanks
Last edited by trastrestris; December 13th, 2011 at 01:55 PM.
-
December 13th, 2011, 02:32 PM
#2
Re: Find ASP element by ID
I did it!, it was so much simple than what I thought. Trying hundreds of hundreds of combinations, I got this:
PHP Code:
Dim MyControl As Control = Me.Form.FindControl("MainContenedor") MsgBox(MyControl.FindControl("chkFila_1").ID)
The code works for both Master and Child. I think I should always post here before fighting the code "Every time I ask something is when my brain starts to work...
Thanks and Thread solved.
Bye
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|