Home All Groups Group Topic Archive Search About

How to initiate a postback in a function?

Author
24 Nov 2005 11:36 AM
cin
I would like to initiate a postback after I  have finish executing some codes
in a dynamically created button_click event. Do anyone know? Please help!!!
Thanks

Author
24 Nov 2005 12:22 PM
Edwin Knoppert
<script language=javascript>
function hello(){ <%=
Page.ClientScript.GetPostBackEventReference(Me.cmdHello, "")%> }
</script>


Show quoteHide quote
"cin" <c**@discussions.microsoft.com> schreef in bericht
news:ABCC2C76-DC31-484A-A166-15ED697D7487@microsoft.com...
>I would like to initiate a postback after I  have finish executing some
>codes
> in a dynamically created button_click event. Do anyone know? Please
> help!!!
> Thanks
>
Are all your drivers up to date? click for free checkup

Author
24 Nov 2005 2:40 PM
Wouter van Vugt
Hi Edwin,

do something like you posted above:

<script runat="server">
    protected override void OnLoad(EventArgs e)
    {
        string script = "function CustomPostback(){ " +
            Page.ClientScript.GetPostBackEventReference(this, null) + "
}";
        Page.ClientScript.RegisterClientScriptBlock(
            GetType(), "MyScript", script, true);
        base.OnLoad(e);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="button" onclick="CustomPostback();" />
    </div>
    </form>
</body>
</html>

This is ASP.NET 2.0 code, in ASP.NET 1.1, the methods can be found on
the Page class, e.g. Page.RegisterClientScriptBlock.

Grtz, Wouter
Trainer - Info Support - www.infosupport.com
www.dive-in-it.nl

Bookmark and Share