This is a migrated thread and some comments may be shown as answers.

Loading User Control with DropDownList

3 Answers 149 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Haderach
Top achievements
Rank 1
Haderach asked on 31 Aug 2007, 01:48 PM
Hello,

I am working with your LoadingUserControls example.
I understand your example but in what I want to do, it is slight different because in the ASCX I want to load, I have a part of code which I want to be loaded only if Page.IsPostBack is false....

To be more precise, on the ASCX Page_Load, I have :

if (IsPostBack)  
    return;  
 
BindingDropDownList(); 

I really need to have the DropDownList bind here.

Do you have any solution for such a problem?

Thank for your time.

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 03 Sep 2007, 10:46 AM
Hi Haderach,

Although I am not sure whether I am on the right path, from your description I assume that you would like to execute the dropdown list binding code on PageLoad of the user control only once after the user control is loaded dynamically. Additionally, I suppose that the runtime load is after the initial load of the page.

Is this information correct? If this is what you are after, I suggest you implement boolean property for your user control which can be used as a flag whether this user control is loaded for the first time or not. Changing the value of this property will indicate whether the binding logic should be executed or not.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Deano
Top achievements
Rank 1
answered on 13 Sep 2007, 02:52 PM
How do you implement the boolean for the dropdown.
I also have the same situation where I want to load the control within the User control only on the first time it loads, not the container loading.
How do you set the boolean and have it persist on postback of the user control?

Thanks
Dean
p.s could you reply to ouellette.dm@forces.gc.ca I am unable to get my deanouellette@yahoo.ca account at work.
0
Haderach
Top achievements
Rank 1
answered on 13 Sep 2007, 03:15 PM
Hello,

I've done things like that :

 protected bool IsFirstLoad  
        {  
            get  
            {  
                if (!Object.ReferenceEquals(ViewState["isFirstLoad"], null))  
                    return System.Convert.ToBoolean(ViewState["isFirstLoad"]);  
                else  
                    return true;  
            }  
            set  
            {  
                ViewState["isFirstLoad"] = value;  
            }  
        }  
 
protected void Page_Load(object sender, EventArgs e)  
    {  
          
        //if (IsPostBack)  
        //    return;  
 
        if (!IsFirstLoad)  
            return;  
 
        if (IsFirstLoad)  
            IsFirstLoad = false;  
    } 


Hope it will help.
Tags
Ajax
Asked by
Haderach
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Deano
Top achievements
Rank 1
Haderach
Top achievements
Rank 1
Share this question
or