can we store viewstate in masterpage?
-
I really appreciate your help. but still i have to make changes in all the content pages(i.e. globally) right. Isn't there way by which i have to make changes in the masterpage itself?
Everything Is Possible!
No you can do that in Masterpage as well. Just write your code in masterpage page_load and it will work perfectly. :)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
No you can do that in Masterpage as well. Just write your code in masterpage page_load and it will work perfectly. :)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using JavascriptNo dear, it does not work.
Everything Is Possible!
-
No dear, it does not work.
Everything Is Possible!
Tell me what you did so far. Just do like this : write Response.Cookies["txtCookie"].Value = myid; Response.Cookies["txtCookie"].Expires = DateTime.Now.AddDays(1); inside your masterpage, and it will be accessible to any page that inherits masterpage (also normal pages) I have done this a lot of times, and it worked perfectly... To request the cookie use Request.Cookies["txtCookie"] :-D
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
Tell me what you did so far. Just do like this : write Response.Cookies["txtCookie"].Value = myid; Response.Cookies["txtCookie"].Expires = DateTime.Now.AddDays(1); inside your masterpage, and it will be accessible to any page that inherits masterpage (also normal pages) I have done this a lot of times, and it worked perfectly... To request the cookie use Request.Cookies["txtCookie"] :-D
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascriptbut my id keeps on changing depending on the no. of tabs opened(Firefox). And Each tab has to maintain different ids(customerId for instance). Example I have a gridview having multiple customers. if i open multiple customer details on multiple tabs then there should be different customerid assigned to different pages. In case if i use cookie then it will store a single customerid and when the page makes a request then this id will be assigned to all the pages. I dont want to do like this. I dont think, this is a solution(i.e. Cookie)
Everything Is Possible!
-
can we store viewstate in masterpage. so that when a user tries to open a new tab, the id is fetched from the viewstate.
Everything Is Possible!
Create the public property in Master page. Cast the master page in content page
MasterPage mymasterpage = Page.Master as MyMasterPage;
Use the property in content page to access the customer name.
Response.Write(mymasterpage.CustomerName);
Try it, if it is working
Regards Aftab Sindhi .NET Application Developer U.A.E
-
but my id keeps on changing depending on the no. of tabs opened(Firefox). And Each tab has to maintain different ids(customerId for instance). Example I have a gridview having multiple customers. if i open multiple customer details on multiple tabs then there should be different customerid assigned to different pages. In case if i use cookie then it will store a single customerid and when the page makes a request then this id will be assigned to all the pages. I dont want to do like this. I dont think, this is a solution(i.e. Cookie)
Everything Is Possible!
Ok.. As per your requirement is concerned, I think database is the best solution. Even If I was doing this application, I will always use Database. Actually session/viewstate cannot be used to do what you want.. .thats for sure. Other than that, you can use Application object which will reflect to all the session, ... But believe me, from my personal experience I would suggest not to use it, because Server memory is very important, and if your application is using excessive server memory, it may be of high probability of getting the site down any time. So, You have only 2 option, 1. Cookie (Which you dont want) : you can store as many customer ids as you want. As this is stored in client side, performance will not be hampered for the site. 2. Database / XML file in server : I think this is the best way. Its secured and everyone in your situation would have chosen this. Now it depends on you which one you choose. Let me know about it. :rose::rose:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
Create the public property in Master page. Cast the master page in content page
MasterPage mymasterpage = Page.Master as MyMasterPage;
Use the property in content page to access the customer name.
Response.Write(mymasterpage.CustomerName);
Try it, if it is working
Regards Aftab Sindhi .NET Application Developer U.A.E
I dont want to make changes in all the content pages because there are around 40-50 pages.It's tedious to incorporate this changes to all the files. Is there a way by which i have to modify only the master page?
Everything Is Possible!
-
Ok.. As per your requirement is concerned, I think database is the best solution. Even If I was doing this application, I will always use Database. Actually session/viewstate cannot be used to do what you want.. .thats for sure. Other than that, you can use Application object which will reflect to all the session, ... But believe me, from my personal experience I would suggest not to use it, because Server memory is very important, and if your application is using excessive server memory, it may be of high probability of getting the site down any time. So, You have only 2 option, 1. Cookie (Which you dont want) : you can store as many customer ids as you want. As this is stored in client side, performance will not be hampered for the site. 2. Database / XML file in server : I think this is the best way. Its secured and everyone in your situation would have chosen this. Now it depends on you which one you choose. Let me know about it. :rose::rose:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using JavascriptI really appreciate your help but i dont think this is a better solution. I would rather create a public property in the masterpage and cast the masterpage in all my content pages(there are around 40-50 pages). although it is a tedious work. I will store the id in the content page's viewstate.
Everything Is Possible!
-
I really appreciate your help but i dont think this is a better solution. I would rather create a public property in the masterpage and cast the masterpage in all my content pages(there are around 40-50 pages). although it is a tedious work. I will store the id in the content page's viewstate.
Everything Is Possible!
:laugh: But where it will get the Id ... In server side ?? Id should be stored at least somewhere to communicate. Do you think only a property can make things ok. Every time a web request is made a new object of the whole page will be created. If you open a new tab, there will be no communication between the original page(Even session is different) So it will always hold the default value of the property. Viewstate will be refreshed for every page, so it cant get the values that you created in another page. Anyways... thanks for your appreciation. But I am still not sure what you are upto... Best wishes. :cool:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
:laugh: But where it will get the Id ... In server side ?? Id should be stored at least somewhere to communicate. Do you think only a property can make things ok. Every time a web request is made a new object of the whole page will be created. If you open a new tab, there will be no communication between the original page(Even session is different) So it will always hold the default value of the property. Viewstate will be refreshed for every page, so it cant get the values that you created in another page. Anyways... thanks for your appreciation. But I am still not sure what you are upto... Best wishes. :cool:
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using JavascriptI will assign the viewstate to the property. Regards, Suresh Dayma
Everything Is Possible!