Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6986713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:50:40+00:00 2026-05-27T18:50:40+00:00

I have the following aspx/html page, it uses jquery to display a modal form.

  • 0

I have the following aspx/html page, it uses jquery to display a modal form. Every time I click on a jquery modal generated button it does a post back on the form. I would like to stop this.
Below is my script

    < script type = "text/javascript" > $(function () {
     $(".addNew").dialog({
         autoOpen: false,
         width: 300,
         height: 300,
         resizeable: false,
         title: 'New Item',
         modal: true,
         close: function (event, ui) {
             event.preventDefault();
             location.reload(false);
             return false;
         },
         buttons: {
             "Add": function (evt) {
                 evt.preventDefault();
                 var name = $("#<%= txtName.ClientID  %>").val();
                 var surname = $("#<%= txtSurname.ClientID %>").val();
                 var age = $("#<%= txtAge.ClientID %>").val();

                 if (Page_ClientValidate("Person")) {
                     $.ajax({
                         type: 'POST',
                         url: 'Dialog.aspx/AddNewItem',
                         data: '{"name":"' + name + '", "surname":"' + surname + '", "age":' + age + '}',
                         contentType: "application/json; charset=utf-8",
                         dataType: "json",
                         success: function (msg) {
                             if (msg.d) {
                                 $("#user").append("<li>" + name + "</li>");
                             }
                         },
                         error: function () {
                             alert("Error! Try again...");
                         }
                     });
                 }
             },
             "Cancel": function (evt) {
                 evt.preventDefault();
                 $(this).dialog("close");
                 return false;

             }
         }
     });

     $("#add").click(function (event) {
         event.preventDefault();
         $(".addNew").dialog("open");
         return false;
     });
 });

<a href="#" id="add">Add New</a>
<form id="form1" runat="server">
<div>

    UserName
        <asp:TextBox ID="UserName" runat="server" />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please enter a username" Display="None" ControlToValidate="UserName" ></asp:RequiredFieldValidator>
 </div>
 <ul id="user">


 </ul>



<div class="addNew" title="Add new Person">
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Person" />
<table>
    <tr>
        <td>Name</td>
        <td><asp:TextBox ID="txtName" runat="server" /></td>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter a name" Display="None" ControlToValidate="txtName" ValidationGroup="Person"></asp:RequiredFieldValidator>
    </tr>
    <tr>
        <td>Surname</td>
        <td><asp:TextBox ID="txtSurname" runat="server" /></td>
    </tr>
    <tr>
        <td>Age</td>
        <td><asp:TextBox ID="txtAge" runat="server" /></td>
    </tr>
</table>
</div>  

</form>
</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:50:40+00:00Added an answer on May 27, 2026 at 6:50 pm

    Reposing comment as answer:

    The issue is that your code is explicitly calling location.reload() inside dialog’s close handler. It is not doing anything useful beyond that, so you can probably remove close handler entirely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML content. When i click the button, the page doesn't
I have the following webform: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=TestWebApp.Default %> <!DOCTYPE html
I have following simple code: <%@ Page Language=C# AutoEventWireup=true CodeBehind=testForm.aspx.cs Inherits=Orbs.testForm %> <html> <body>
I have the following html snippet: <a href=page1.aspx class=title>page title goes here</a><br /> <span
I have the following ASPX page: <html xmlns=http://www.w3.org/1999/xhtml > <head runat=server> <title></title> <script src=js/jquery-1.2.6.min.js
I have the following test ASPX page: <head runat=server> <title></title> <script src=js/jquery-1.2.6.min.js type=text/javascript></script> <script
I have following abc.aspx file: <%@ Page Language=vb AutoEventWireup=false Codefile=abc.aspx.vb Inherits=abc %> <html xmlns=http://www.w3.org/1999/xhtml>
I have the following in an aspx page: <td colspan=2> <% DisplayParties(); %> </td>
I have a URL string in the following format. http://myserver.com/_layouts/feed.aspx?xsl=4&amp;web=%2F&amp;page=dda3fd10-c776-4d69-8c55-2f1c74b343e2&amp;wp=476f174a-82df-4611-a3df-e13255d97533 I want to replace
Morning stackoverflow, I have a repeater, with the following code in my aspx page;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.