is there any way to access parent page ViewState from the user control.
Yes you can ... To do so you just need to follow a basic trick ..
First inherit the caller page by a base page (using a base page over the project always a good practice it help later very much) like below ...
public abstract class BasePage : Page
{
public StateBag ViewState
{
get
{
return base.ViewState;
}
}
}
Later you can call this property from usercontrol ........
var CallerPage = this.Page as BasePage;
if (CallerPage!=null)
{
var CallerPageViewState = CallerPage.ViewState;
//Do your rest job
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With