Find control in RadPanelBar and assign it to new one

1 posts, 0 answers
  1. Mohamed
    Mohamed avatar
    7 posts
    Member since:
    Oct 2012

    Posted 11 Apr 2013 Link to this post

    Here's the working code:

    In the page.aspx.cs, I define a static variable:

    private static TextBox txtName;


    In the Page_Load() event, I initialize it:

    txtName = (TextBox)RadPanelBar1.FindItemByValue("Add").Controls[0].FindControl("TxtName");

    The questions is:
    1- I had to make the textbox "static" to make the code work, why?
    2- The initialization code didn't work when I put it in the if (!IsPostBack) block, I had to make it run  in every page load. why? and is there a better approach to achieve the same functionality?





Back to Top