Use MasterPage's Viewstate In ContentPage?
Feb 10, 2010Asp.net: Can we use MasterPage's viewstate in ContentPage ?
View 1 RepliesAsp.net: Can we use MasterPage's viewstate in ContentPage ?
View 1 RepliesI am trying to get value of a variable"offset" code behind of content page which is set from default.aspx through onload event from master page.But it gives null value every time. Here is my code.
Maste.aspx
---------
<head>
<asp:ContentPlaceHolder runat="server" id="Headers"> [code]....
I have a FreeTextBox control on a page that has a masterpage. This FreeTextBox control is in the maincontent.
View 5 RepliesI have a unordered list in my master page....
<ul id="mainMenu" runat="server">
<li id="mainHome" runat="server"><a href="#" title="Home" class="home">
<span></span>Home</a></li>
<li id="mainManage" runat="server"><a href="Users.aspx" title="Manage"
class="manage"><span></span>Manage</a></li>
<li id="mainEnquiry" runat="server"><a href="account.aspx" title="Enquiry"
class="enquiry"><span></span>Enquiry</a></li>
<li id="mainReport" runat="server"><a href="EnquiryReport.aspx" title="Report"
class="report"><span></span>Report</a></li>
</ul>
From a content page i am assigning a css class to one of the list item.
HtmlGenericControl home = (HtmlGenericControl)this.Page.Master.FindControl("mainMenu").FindControl("mainManage") as HtmlGenericControl;
string cssToApply = "current";
if (null != home)
{
if (home.Attributes.ContainsKey("class"))
{
if (!home.Attributes["class"].Contains(cssToApply))
{
home.Attributes["class"] += " " + cssToApply;
}
}
else
{
home.Attributes.Add("class", cssToApply);
}
}
and my css,
#header ul li {
display:inline;
float:left;
}
#header ul a {
-x-system-font:none;
color:#FFFFFF;
display:block;
font-family:Trebuchet MS,Arial,sans-serif;
font-size:1.1em;
font-style:normal;
font-variant:normal;
font-weight:bold;
text-transform:uppercase;
text-decoration:none;
}
#header ul a {
-moz-border-radius:3px;
-webkit-border-radius:0.2em;
padding:3px 7px;
text-decoration:none;
}
#header ul a:focus, #header ul a:active, #header ul a:hover {
background-color:#829E7E;
outline-color:-moz-use-text-color;
outline-style:none;
outline-width:medium;
}
#header ul a.home {
margin:0 16px 0 17px;
}
#header ul #current a, #headermenu #current span{ /*currently selected tab*/
background-color: #BCE27F;
color:#666666;
white-space:nowrap;
}
#header ul a.manage,#header ul a.enquiry,#header ul a.report {
margin:0 14px 0 0;
}
#home #header ul a.home, #enquiry #header ul a.enquiry, #report #header ul a.report, #manage #header ul a.manage{
-moz-border-radius:3px;
-webkit-border-radius:0.2em;
background-color:#B9E27F;
color:#FFFFFF;
}
But i get the error, System.Web.UI.AttributeCollection' does not contain a definition for 'ContainsKey' and no extension method 'ContainsKey' accepting a first argument of type 'System.Web.UI.AttributeCollection' could be found (are you missing a using directive or an assembly reference?
I have a masterpage with a timer that shows server time and refreshes every second, on the content page I have a chat program with ajax, refreshes every to second to get the last messages entered.
I have a Html TextBox and a hidden Submit Button, when user write a text, and hit the enter, I check to see if this is the enter key and then submit the message,it is working perfectly in IE, but in FireFox and Opera it show the same message twice. I think the problem is the Timer, is there any way to avoid the MasterPage timer in this particular content page?
I have applied my stylesheet in my masterpage the following way:
[Code]....
In my contentpage I wish to change the stylesheet of my masterpage, but I'm not sure how to reference to it.
I've tried the following, but I can't scope to the "test".
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
test.Href = "~/CSS/AlternativeMenu";
}
</script>
We have a master page file in which we have a MenuControl. We are displaying some menus according to users credentials. We are handling MenuItemDataBound event inside master page for adding & removing menus.
There is user edit page{ContentPage} on which user may edit his own credentials. After saving the edited data {users credentials} by ASP.Net Button control, the MasterPage's MenuItemDataBound event doesn't fire (in case of refresh it is firing but in case of post back it is not firing).
We need to recreate/refresh MenuItems for master pages after saving the user and add/remove any nodes from Menus.
how to set the body class of a ContentPage when using master pages?
I want to set the body class so that certain elements of my page are styles differently from each other. e.g. Navigation links to so which is the current page.
I am using a Masterpage for my upload_photo.aspx which displays the file upload page using colorBox. However, ever since i added (code below) in the Masterpage colorBox doesn't display:
<script type="text/javascript">
$(function () {
$("#txtAutoCompleteSearch").AutoComplete("search.aspx?searchword=");
[code]...
I have a DateTime in my MasterPage.aspx that is outside of UpdatePanel1. There are two Hyperlink controls inside UpadatePanel1 to navigate or to move to the other pages. Full code of MasterPage.aspx is below.
[Code]....
If the user clicks Hyperlink to navigate or move to the other page, the DateTime will change. It means that my MasterPage.aspx render the whole page when the user clicks Hyperlink. I do not want this behavior. I want my MasterPage.aspx only render the ContentPage and the
Hyperlink inside UpadtePanel1. Controls outside UpadtePanel1 like DateTime should not be rendered again. Please advise the code to achieve my example goal.
Can I update masterpage's updatepanel from content page.
suppose that i have an updatepanel in masterpage like as follows..
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</ContentTemplate>
</asp:UpdatePanel>
Can i change that Literal1's text from contentpage ?
Im having a master page which consists an user control further which consists a Label.i want to change the text of that label in content page.
View 7 RepliesI'm looking to do a short term hack on a site. The site is a ASP.NET site with a master page. The body tag is in the master page. I'd like to specify which ID should be in the body tag from within various content pages. What I don't know is if you can have this type of access to the body tag when your JS is within the body tag. For various reasons, I'd like to try to accomplish this in JS, not .NET.
Rephrasing for clarity: I would like to use JavaScript to specify a body ID from within the body tag of a site. For example:
<body id="MyID">
JS to change MyID to another name
</body>
I have a page which is connected to master page. With the controls checkbox and textbox. If check box checked it should disable the textbox control using javascript. how to use javascipt in contentpage with master page?
View 5 Replies I have problem when i use UpdatePanel in ContentPage. In Updatepanel, I have DataGrid. Outside, I have a textbox and Button.
When i press button, I want to insert message in texttbox to Database and Select from Database for Showing in DataGrid (includes all message in past)
My MasterPage:
<ScriptManager>
<ContentPlaceHolder>
My ContentPage
<div> Have a textbox and button
<updatePanel> Have Datagrid
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="commentForm1.aspx.cs" Inherits="ChatApplication.commentForm1" %>
Now here is the weird thing. First i am running it locally on the built in vs2008 web server.I load my control in fine, do a postback from a linkbutton, locally on my machine it all works fine, no issue.However when it goes onto my host, it falls over with the message:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.Now i also load controls dynamically and use postbacks and things in the admin area of the site...and that works fine, however my front end just keeps failing? See the code behing below:
[Code]....
I have problem getting values from viewstate in GetTopThemes.
<asp:ObjectDataSource
ID="sourceGetTopThemes"
runat="server"
TypeName="DBConnection"
SelectMethod="GetTopThemes"
EnableViewState="true"></asp:ObjectDataSource>
[Code]....
}
[Code]....
when the page is not Posted back, I saved all values in the viewstate.
How would you access a method in a contentpage from a code module?
View 2 RepliesI have been getting this error a lot lately with some of my users, and I had a couple of concerns with view state and I have read so many articles but I am still lost..
1. I use masterpage on all the pages and I need viewstate for some of the pages but..
There is a page where a user will fill out the information and then submit this data to a cgi server, and it is where I get most of the Client Disconnected errors, what would happen if I disable viewstate when they click on that button?
Now when a user browses from one page to another, does the view state from the previous page get deleted? If not how would I delete it?
Does the master page have its own viewstate? Would I be able to make sure none of items on my master page are using the viewstate?
I have a shopping cart page (Cart.aspx) that has a button that will (sometimes) post to a third party payment gateway, if payment is necessary. The payment gateway will process the payment and then do a silent post to my website (Order.aspx) so I can update the order status.
Order.aspx always throws an invalid viewstate error, even though viewstate is disabled on the page.
What's happening is that Cart.aspx (which has viewstate enabled) posts to the payment gateway, and the gateway will post it back as part of the silent post. Even though Order.aspx has viewstate disabled and validation disabled, it still tries to validate the __viewstate field it's being given.
I know setting EnableViewState=false will disable the rendering of the __viewstate field, but if another page provides the field, shouldn't it still skip validation? I tried calling ViewState.Clear() on the Page_Init event of Order.aspx, but ViewState is apparently empty. how to get around this? I don't want to disable ViewState on Cart.aspx (in some cases it may be necessary), but I can't figure out how to clear it on Order.aspx.
I have a MasterPage (MasterPage.master) with 2 child MasterPages (specialMaster.master and standardMaster.master). From the MasterPage.master I need to get at some of the controls in one of the children, specialMaster.master, say for example to hide certain
content if a session variable is not null.
I have 2 masterpages. (Default.master and User.master).I have a hidden field in Default.master then how can i get the hidden field value of Default.master file from User.master.is there any way to access that hidden field like: Request.form("hidID") ?
View 2 RepliesI have added one datalist into view state as:
ViewState["datalist"] = dtlstForm;
and retrieved it as:
DataList lis = (DataList)ViewState["datalist"];
then folowing error comes:
Type 'System.Web.UI.WebControls.DataList' in Assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
I have an aspx page that I want to convert to an HttpHandler, but I'm struggling withewState that's been used in the code behind of the aspx page
View 2 RepliesUpon page reloads I want to retain the values the user had typed in upon hitting submit. I worry about viewstates being cumbersome for pages, both in bandwidth and in time for a page viewer to download the page. I am cheap with my bytes :p
My question is instead of using server controls and such I am having the form on the page do a get to itself and on the aspx putting <input type="text" id="user_email" name="email" value="<%=Request.Form["email"] %>" /> This allows me to not use viewstate. Are there any potential shortcomings to doing things this way? My goal is always for a lighter page and efficiency even if it is more work.