Quantcast
Channel: nxajax Wiki Rss Feed
Viewing all articles
Browse latest Browse all 20

Updated Wiki: Ajax Form Example

$
0
0

Ajax Form Example

Currently, the Form control from nxAjax library is in testing phase

Open Quick Example and Add a new WebForm named Default2.aspx:

<system.web>
<%@PageLanguage="C#"EnableEventValidation="False"AutoEventWireup="true"CodeFile="Default2.aspx.cs"Inherits="Default2"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><headrunat="server"><title>Don't use it, it does not works... :(</title></head><body><ajax:Formrunat="server"ID="formu"><div><ajax:ButtonID="btnOne"Value="One"runat="server"OnServerClick="btnOne_ServerClick"></ajax:Button><ajax:ButtonID="btnTwo"Value="Two"runat="server"OnServerClick="btnTwo_ServerClick"></ajax:Button><ajax:TextBoxID="txtOne"runat="server"Value="One"></ajax:TextBox><ajax:SubmitID="submitOne"runat="server"OnServerClick="submitOne_ServerClick"></ajax:Submit></div></ajax:Form><formid="form1"runat="server"><div><asp:ButtonID="btnAsp"Text="Asp"runat="server"OnClick="btnAsp_Click"/><asp:TextBoxID="txtAsp"Text="" AutoPostBack="True"runat="server"OnTextChanged="btnAsp_Click"/></div></form></body></html></system.web>

In order to it works properly you should modify the WebForm Properties:
EnableViewState = true;
EnableEventValidation = false;
ViewStateEncryptionMode = System.Web.UI.ViewStateEncryptionMode.Never;
EnableViewStateMac = false;

And add in the code behind the event code management. The final result should be something like:
using System;
using System.Collections.Generic;
using System.Linq;

using Framework.Ajax.UI;
using Framework.Ajax.UI.Controls;

publicpartialclass Default2 : System.Web.UI.Page
{
    public Default2() : base()
    {
        this.EnableViewState = true;
        this.EnableEventValidation = false;
        this.ViewStateEncryptionMode = System.Web.UI.ViewStateEncryptionMode.Never;
        this.EnableViewStateMac = false;
    }
    protectedvoid Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
        }
    }
    protectedvoid btnOne_ServerClick(AjaxControl sender, string value)
    {
        btnOne.AjaxController.DocumentAlert("Hi!! " + value);
        txtOne.Value = "Three";
    }
    protectedvoid submitOne_ServerClick(AjaxControl sender, string value)
    {
        txtOne.Value = "One";
    }
    protectedvoid btnTwo_ServerClick(AjaxControl sender, string value)
    {
        btnOne.AjaxController.DocumentAlert("Hi!! " + value);
        txtOne.Value = "Two";
    }
    protectedvoid btnAsp_Click(object sender, EventArgs e)
    {
        txtOne.AjaxController.DocumentAlert("Hi! " + btnAsp.Text);
        txtOne.Value = "Three";
    }
}

Do not forget comment your experiences ;)

Viewing all articles
Browse latest Browse all 20

Trending Articles



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