Error due to Site.Master file - asp.net using c# -
i receiving error due site.master file. have made numerous adjustments , still cannot past issue site.master file. have wrong specification perhaps? code executes in microsoft visual studios, when export site files hosted servers run issues.
compiler error message: cs1002: ; expected
line 1365: system.web.ui.webcontrols.listviewdataitem
container; line 1366: system.web.ui.databoundliteralcontrol target;
line 1367:
across-america.models.category item;
line 83 "e:\server\user\across-america\site.master"
the error due following:
<asp:listview id="categorylist" itemtype="across-america.models.category" runat="server" selectmethod="getcategories">
i have modified temtype="across-america.models.category" remove across-america still error. advice???
c# code error:
<div id="categorymenu" style="text-align: center"> <asp:listview id="categorylist" itemtype="models.category" runat="server" selectmethod="getcategories"> <itemtemplate> <b style="font-size: large; font-style: normal"> <a href="/productlist.aspx?id=<%#: item.categoryid %>"> <%#: item.categoryname %> </a> </b> </itemtemplate> <itemseparatortemplate> | </itemseparatortemplate> </asp:listview> </div>
models class in category.cs:
using system.collections.generic; using system.componentmodel.dataannotations; namespace models { public class category { [scaffoldcolumn(false)] public int categoryid { get; set; } [required, stringlength(100), display(name = "name")] public string categoryname { get; set; } [display(name = "product description")] public string description { get; set; } public virtual icollection<product> products { get; set; } } }
site.master models reference, towards end of code:
using models; using across-america.logic; namespace across-america { public partial class sitemaster : masterpage { private const string antixsrftokenkey = "__antixsrftoken"; private const string antixsrfusernamekey = "__antixsrfusername"; private string _antixsrftokenvalue; protected void page_init(object sender, eventargs e) { // code below helps protect against xsrf attacks var requestcookie = request.cookies[antixsrftokenkey]; guid requestcookieguidvalue; if (requestcookie != null && guid.tryparse(requestcookie.value, out requestcookieguidvalue)) { // use anti-xsrf token cookie _antixsrftokenvalue = requestcookie.value; page.viewstateuserkey = _antixsrftokenvalue; } else { // generate new anti-xsrf token , save cookie _antixsrftokenvalue = guid.newguid().tostring("n"); page.viewstateuserkey = _antixsrftokenvalue; var responsecookie = new httpcookie(antixsrftokenkey) { httponly = true, value = _antixsrftokenvalue }; if (formsauthentication.requiressl && request.issecureconnection) { responsecookie.secure = true; } response.cookies.set(responsecookie); } page.preload += master_page_preload; } protected void master_page_preload(object sender, eventargs e) { if (!ispostback) { // set anti-xsrf token viewstate[antixsrftokenkey] = page.viewstateuserkey; viewstate[antixsrfusernamekey] = context.user.identity.name ?? string.empty; } else { // validate anti-xsrf token if ((string)viewstate[antixsrftokenkey] != _antixsrftokenvalue || (string)viewstate[antixsrfusernamekey] != (context.user.identity.name ?? string.empty)) { throw new invalidoperationexception("validation of anti-xsrf token failed."); } } } protected void page_load(object sender, eventargs e) { } protected void page_prerender(object sender, eventargs e) { using (shoppingcartactions usersshoppingcart = new shoppingcartactions()) { string cartstr = string.format("cart ({0})", usersshoppingcart.getcount()); cartcount.innertext = cartstr; } } public iqueryable<category> getcategories() { var _db = new models.productcontext(); iqueryable<category> query = _db.categories; return query; } protected void unnamed_loggingout(object sender, logincanceleventargs e) { context.getowincontext().authentication.signout(defaultauthenticationtypes.applicationcookie); } } }
Comments
Post a Comment