Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

MasterPage Problem

$
0
0

this is the contentplaceholder code 

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="myadminarea.aspx.cs" Inherits="Codester.myadminarea" %><asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"><asp:UpdatePanel runat="server" ID="upcats" ChildrenAsTriggers="true" UpdateMode="Conditional"><ContentTemplate><div class="float-left"><form class="form form-horizontal"><label>Category-Name</label><input type="text" runat="server" id="txtnamecat" class="form-control" required="required" /><label>Category-Description</label><textarea runat="server" id="txtdescription" rows="5" class="form-control" required="required"></textarea><br />  <asp:Button  runat="server"  ID="btnadd" class="btn btn-danger" OnClick="btnadd_Click" Text="Create" /><input type="reset" id="btnreset" class="btn btn-danger" value="Reset"  /></form></div><div class="float-right"><asp:GridView runat="server" CssClass="table table-hover" ID="gvcats" AllowPaging="true" PageSize="5" AutoGenerateColumns="false"><EmptyDataTemplate><h1>sorry no result found.</h1></EmptyDataTemplate><Columns><asp:BoundField DataField="Cat-Id" HeaderText="Cat-Id" ReadOnly="true" /><asp:BoundField DataField="Cat-Name" HeaderText="Cat-Name" /><asp:BoundField DataField="Cat-Description" HeaderText="Cat-Description" /></Columns></asp:GridView><input type="submit" id="btndelete" class="btn btn-danger" value="Update" /><input type="submit" id="btnupdate" class="btn btn-danger" value="Delete" /> </div></ContentTemplate></asp:UpdatePanel></asp:Content>

this is code behind for this web page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Codester.App_Code;
using System.Data;

namespace Codester
{
    public partial class myadminarea : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                gvcats.DataSource =DB.ExecuteReader("CatsProcuder");
               gvcats.DataBind();
            }

        }

        protected void btnadd_Click(object sender, EventArgs e)
        {
            DB.ExecuteNonqueryInsert("Catsinsertprocuder");
        }
    }
}


 yhis is masterpage control code 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Codester
{
    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)
        {
            // The code below helps to protect against XSRF attacks
            var requestCookie = Request.Cookies[AntiXsrfTokenKey];
            Guid requestCookieGuidValue;
            if (requestCookie != null && Guid.TryParse(requestCookie.Value, out requestCookieGuidValue))
            {
                // Use the Anti-XSRF token from the cookie
                _antiXsrfTokenValue = requestCookie.Value;
                Page.ViewStateUserKey = _antiXsrfTokenValue;
            }
            else
            {
                // Generate a new Anti-XSRF token and save to the 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;// error fire at this line .
        }

        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 the 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)
        {

        }
    }
}
 Page.PreLoad += master_Page_PreLoad;// error fire at this line 

Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>