Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to display a jquery popup post completion of some server side validation. how to achieve this.

protected void linkbutton_Click(object sender, EventArgs e)
{
if()
{ Some validation}
Else
{
//need to display a jquery popup
}
}


if i need to call with Javascript, how to call a js function from aspx.cs page

What I have tried:

.ASPX.CS page

<pre>protected void linkbutton_Click(object sender, EventArgs e)
{
if()
{ Some validation}
Else
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"alert", "alertfunction();", true);
}
}



.ASPX page

<script lang="javascript" type="text/javascript">
   $(function () {
            $("#divid").dialog({
                autoOpen: false
            });
        })

        
        function alertfunction() {
            $("#divid").dialog('open');
        }
</script>

No Records Found


if i am trying this dialog is not a function is showing as error and Javascript call is not happening
Posted
Updated 22-Aug-19 4:07am

1 solution

Assuming everything else is fine, your alertfunction will fire before your $(...) function so you are opening a dialog on a div that hasn't been attached yet. Move the ".dialog" init code into your alertfunction method too.

Other than that check the console for errors.
 
Share this answer
 
Comments
Virendra S from Bangalore, Karnataka 22-Aug-19 12:21pm    
Didn't worked, dialog is not a function, ans with sample code would be appreciated

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900