I have registered a usercontrol dynamically and called it in page load.
In Button click i used "Viewstate.clear" , for that usercontrol but it is not working.
Can anybody suggest me to clear the Viewstate.
Thank u,
Related
Please I need someone to help me with this issue:
When I select an item from an .ascx usercontrol 'DropDownList Box' added to a master page with PlaceHolder1.Controls.Add(LoadControl("//UserControls/mycontrol.ascx"));
The .ascx user control disappears after the item has been selected
You don't show your code, so it's hard to provide an exact answer. but probably you add your user control dynamically only one time and it disappears after each postback.
You need to load Usercontrol after each postback so you need to load Usercontrol in something like Page_load method if you don't.
I have a ASP.Net(C#) page. When a user selects a value in dropdownlist, some new controls will be visible to him.
I am able to that now, but the page has to reload every time and state has to be maintained between postbacks.
Is there any way to do the same without reloading of the page in a easiest way possible without using ajax control toolkit?
Additional info: the data for the dropdownlist is coming from the database, and some places it has to be all server side so i can't use javascript .
You can try this idea: http://msdn.microsoft.com/en-us/library/ms178208(v=vs.100).aspx. I have not try it before but it seems logical.
you should go through updatepanel. Put all the controls inside a updatepanel which you want to show on selectedindexchanged event of the dropdownlist and write code behind on selectedindexchanged event of the dropdownlist accordingly. Hope this will help you...
I have two user controls on a page - UC1,UC2. Each usercontrol have a asp:button. Now if I click the any of the buttons the page post back. Now if I click the button of UC1 then the following happen.
Viewstate load for two user controls.
Page load called for two user controls.
The event handler of UC1 button is fired.
Now if user click on the UC1 button, I do not want to load the view state of UC2 user controls at server because the viewstate of UC2 is large.
The execution of UC1 is not dependent of UC2.
Please suggest how can I achive this.
Thanks!
What it sounds like your asking for is the ability to do partial postbacks. That is postbacks that only affect a portion of the page. There are a number of ways to accomplish this such as using the Microsoft provided AJAX controls (http://www.asp.net/ajax) or rolling your own with JQuery and web methods (this method however is stateless and should be expected as such). Specifically you will want to look at UpdatePanels and PostBack Triggers.
Hope this helps.
I've seen code to handle MasterPage events in the content Page, but if I'm loading a UserControl dynamically into the Page, can I handle the event in the UserControl instead?
Basically I have a button on the MasterPage, when it's clicked I need to make the UserControl do something, such as display text or change a value in a form.
Failing that, is it possible to make an event from one dynamically loaded UserControl fire in another on the same page? I could then replace the button in the MasterPage with one in another UserControl
Thanks all.
This is very similar to this stackoverflow question.
The answer to that question should also apply to yours: your Page knows its master and knows its child controls. It can wire-up a handler on the child control to an event on the master page, so the child control can perform necessary functionality when the even occurs on the master page.
Does Page class adds ViewState for Controls created in CreateChildControls, I mean I have a page which I add some controls to the page and all of them are Literal and EnableViewState is false, my question is are there any ViewState entry gor them in Page's ViewState?
Thank you.
You might want to read this and see if this is what blowing up you page:
http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx
Looks like you can disable view state but your controls can have there own ControlState you might need to worry about.
Also if you are adding these controls into a DataGrid, The DataGrid, stores all of its contents in the view state.
Look here : http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic9