Search content within the blog

Thursday, November 13, 2008

Limiting a User for clicking a button only once while processing$

Control:

<asp:updatepanel id="upOnelick" runat="server">
<contenttemplate>
<asp:Button ID="Button1" runat="server" Text="One Click"
onclick="Button1_Click" />
</contenttemplate>
<triggers>
<asp:asyncpostbacktrigger controlid="Button1" eventname="Click">
</triggers>
</asp:UpdatePanel>
<asp:updatepanel id="upOnelick" runat="server"> <contenttemplate>
<asp:button id="Button1" runat="server" text="One Click" onclick="Button1_Click">
</asp:button>
<triggers>
<asp:asyncpostbacktrigger controlid="Button1" eventname="Click">
</asp:asyncpostbacktrigger>
</triggers>

Javasript:

function pageLoad()
{
var manager = Sys.WebForms.<div id=":g4" class="ArwC7c ckChnd"><$>PageRequestManager.<$>getInstance();
manager.add_initializeRequest(<$>OnInitializeRequest);
}

function OnInitializeRequest(sender, args)
{
var manager = Sys.WebForms.<$>PageRequestManager.<$>getInstance();
// Check if we're posting back because of Button1
if (manager.get_<$>isInAsyncPostBack() && args.get_postBackElement().id.<$>toLowerCase() == "button1")
{
$get("Label1").innerHTML = "Still working on previous request.Please, be patient ...";
args.set_cancel(true);
}
} </div></contenttemplate></asp:updatepanel>

No comments:

Post a Comment