The name 'serializer' does not exist in the current context Master Page Error in For Java Script C# Web App
i have use java script successfully running in my project but when i have to use master page and content page for this purpose i create master page and copy all css and script in the head tag of the master page and rest of the controls in the body tag then i did copy all css and script in the asp:content1 tag while all other thing in the another asp:content2 tag abviously removed all form tags when i compile content page it gave error
"'serializer' does not exist in the current context " in the source file master
actually i use this code in which is actually giving error,
i use this namespace "using System.Web.Script.Serialization;" then use this code in the code behind file,
protected double[] Pvar;
protected JavaScriptSerializer serializer = new
System.Web.Script.Serialization.JavaScriptSerializer();
Pvar[runs] = Convert.ToDouble(output.Tables[0].Rows[runs][2]);
then for accessing this this array in client side javascript i use this code,
var Arr=<%= serializer.Serialize(Pvar)%>;
it giving error in this li开发者_Go百科ne but remember code is correct because it is working on a simple ASPX page on the same time side by using master page and content page ..
Hopes for your suggestions,
From which page, are you accessing the serializer
object? You cannot access protected variable from content code-behind in master page markup and vice versa. So make sure that's not being the case otherwise you need to create public properties/methods and access them by casting Master property in content page (or Page property in Master page) to correct code behind class.
精彩评论