Friday, February 26, 2010

Monday, February 15, 2010

Thursday, February 4, 2010

Wednesday, February 3, 2010

Calling method of a usercontrol from another usercontrol

10:21 AM Posted by Unknown 1 comment
I need to call the method in a usercontrol from another usercontrol. Both controls are placed in same page.
If it is a web application, both controls will be in same namespace. So, we can get their names in the codebehind.

for eg.
if control1 is to be found from control2.
both control1 and control2 are in folder controls. webapplication name is test. So the namespace would be test.control2. Since, both these controls are under the same namespace, we can find the control2 in control1 and vice versa directly.
control2 2 = control1.FindControl("control21") as control2;

But, if this is a website, no namespace. So, we have to add a reference.
Add reference in control1 to find control2.
<%@ Reference Control="~/controls/control2" %>
then, in codebehind,
ASP.controls_control2 2 = this.FindControl("control21") as ASP.controls_control2;

Finding Controls

10:17 AM Posted by Unknown No comments
Check the name of the control in the rendered html. For eg.
I need to find gridview "grdwSelectedCandidates" in usercontrol "SelectedCandidates.ascx" which is inside the ajax tabpanel inside ajax tabcontainer.
I need to find this from another control which is placed in another tabpanel in the same container.
The rendered name is "ctl00_ContentPlaceHolder1_TabContainer1_TabPanel6_SelectedCandidates1_grdwSelectedCandidates"
So, I have to first find content place holder, then, tabcontainer, then, tabpanel, then, control and then gridview.