Post ASP.Net Form data to another page

前端 未结 5 966
终归单人心
终归单人心 2020-12-11 17:58

I have an ASP.Net Page, aspx with its default form.

I have a Submit Button for it. Upon clicking, it will post the data to itself. In othe

5条回答
  •  被撕碎了的回忆
    2020-12-11 18:35

    This is one approach which I don't really recommend but it will do what you want. It uses javascript to change the url (e.g. to default2.aspx) the form is posted to using the form's action attribute and then repost the form

        protected void btnClick(object sender, EventArgs e)
        {
            string script = "";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "postform", script);
        }
    

    The second page should have EnableViewStateMac="false"

    <%@ Page Language="C#" EnableViewStateMac="false" AutoEventWireup="true"
                 CodeBehind="default2.aspx.cs" Inherits="CodeGen.default2" %>
    

    Caution: Turn off MAC generation by setting enableViewStateMac=false in the page or web.config.. This isn't recommended, since the MAC helps prevent people from tampering with your viewstate data. But if tampering with viewstate data isn't a concern (& it may not be for some applications where there's no risk of fraud or security breaches), you can turn it off. Read More

提交回复
热议问题