I want to see how ajax is coded and cut out postbacks in a typical registration form that uses postbacks for data validation and data entry. Thanks.
hello.
well, maybe the easiest approach is to use an updatepanel that wraps the controls on the form.
Please kindly elaborate your idea with detailed sample code. Thanks.
hello.
something like this maybe:
<%@. Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Handle(object sender, EventArgs args)
{
if (!this.IsValid)
{
return;
}
//perform db operations
info.Text = "operation succeeded";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<atlas:ScriptManager runat="server" ID="manager" EnablePartialRendering="true" />
<atlas:UpdatePanel runat="server" ID="Panel">
<ContentTemplate>
<span>Name: </span>
<asp:TextBox runat="server" id="name"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" EnableClientScript="false"
Text="*"
ControlToValidate="name" ErrorMessage="Field name must be filled" />
<br />
<span>Address: </span>
<asp:TextBox runat="server" id="address"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" EnableClientScript="false"
Text="*"
ControlToValidate="address" ErrorMessage="Field address must be filled" />
<br />
<asp:Button runat="server" ID="bt" Text="Confirm" OnClick="Handle" />
<asp:ValidationSummary runat="server" ID="validation" /><br />
<asp:Label runat="server" ID="info" />
</ContentTemplate>
</atlas:UpdatePanel>
</div>
</form>
</body>
</html>
No comments:
Post a Comment