How can you change a Master page dynamically in which event
of page life cycle?
Answers were Sorted based on User's Feedback
Answer / ss
In Page_PreInit(object sender, EventArgs e) Event ...
| Is This Answer Correct ? | 14 Yes | 4 No |
Answer / ashutosh tripathi
Unfortunately there is not built in support to change page
themes at runtime. Here is a simple code which can be used
to change page themes at runtime:
At first though we may say we can easily achieve this by
coding it in Page_Preinit Event as shown below.
protected void Page_PreInit(object sender, EventArgs e)
{
Page.Theme = "Black"
}
But problem with this is we cant assign value from dropdown
box because Page_Preinit event is fired much before
dropdown has changed value.
To resolve this issue, just use the following steps:
1-Create one session variable which will hold current theme
value
2-On selection change event of dropdown combo box , assign
value form combo box to session variable.
3-During Page_preInit Event assign this variable value to
Page.Theme property.
4-Stop page loading and reload same page again using
server.transfer method as shown below
protected void Page_PreInit(object sender, EventArgs e)
{
string thm;
thm = (string)Session["themeSelected"];
if (thm != null)
{
Page.Theme = thm;
DropDownList1.Text = thm;
}
else
{
Session["themeSelected"] = DropDownList1.Text;
Page.Theme = "Blue";
}
protected void DropDownList1_SelectedIndexChanged(object
sender, EventArgs e)
{
Session["themeSelected"] = DropDownList1.Text;
Server.Transfer(Request.FilePath);
}
| Is This Answer Correct ? | 8 Yes | 1 No |
What are the namespace classes used in asp.net mvc? : asp.net mvc
how to implement some securty aspect in our application i.e 1.cookie poisioning. 2.data encryption. 3.forcefull browsing 4.sql/code injection 5.securing web app by using web services ........my question is how to implement these thing in our application is this done by hard coding or by help of some tool
What is the difference between session object and application object?
What is ViewState and How it is managed,Its Advantages/Benefits?
What is the difference between Postback and Ispostback Property?
7 Answers Atrocity Apps Technologies, DC Infotech, HCL, Maples, Visual Soft,
How to use ipostback?
What is Stateless ASP or ASP.Net?
Which Is Faster MVC or ASP.net ?
What is protected configuration?
Can action method static?
What is the use of location tag in web.config file
2 Answers Karur Vysya Bank KVB,
How to send auto matic emails based on scheduled tasks to several of my clients
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)