|
Hi,
I have the following in Main.Master file:
ViewState["member_id"] = Convert.ToString(sql_reader["member_guid"]);
and in banner.ascx which is embedded in the Main.Master, I have the following:
<a href="<%# String.Format("{0}/{1}", Page.RouteData.Values["ADDRESS"], Eval("post_guid")) %>"><img src="<%# String.Format("{0}/{1}/posts/{2}/{3}.png", Application["MemberMediaDirectory"], ViewState["member_guid"], Eval("post_guid"), Eval("member_post_media_guid")) %>" alt="<%# Eval("member_post_media_title") %>" title="<%# Eval("member_post_media_title") %>" width="906px" height="360px" id="<%# Eval("member_post_media_id") %>"/></a>
but the ViewState["member_id"] is getting lost there and it's just blank! how can I fix it please?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Where are you assigning the view state at?
I think you have to assign the value in init in code behind, before page load.
If I remember correct, the webform elements load first, and then page.load fires in the page life cycle
Edit:
My mistake about the master page holding its own view state which is not shared. But I am correct about loaing the viewstate in page.init to hold its value during partial page post backs, and not page load
modified 23-Jan-13 3:15am.
|
|
|
|
|
Jassim Rahma wrote: I have the following in Main.Master file:
...
and in banner.ascx which is embedded in the Main.Master, I have the following:
ViewState is not inherited by child controls. Anything you set in the master page will only be available in the master page.
http://msdn.microsoft.com/en-us/library/ms972976.aspx[^]
If you want to share some state across the entire page, try the Page.Items[^] collection.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|