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 5849325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:59:03+00:00 2026-05-22T12:59:03+00:00

Hello guys and thanks for your help as always. I am stuck on Asp.NET

  • 0

Hello guys and thanks for your help as always.

I am stuck on Asp.NET 2.0 and I am trying to perform a form submit using jquery library.

So far I got the non refresh effect using jquery post method like this:

<script type="text/javascript">

    $(document).ready(function() 
    {


        $("#btnGuardar").click(function()    
        {   
            //post
            $.post("contacto.aspx", {   txtRaz: $("#txtRaz").val(), 
                                        txtDir: $("#txtDir").val(), 
                                        txtEmail: $("#txtEmail").val(), 
                                        txtTel: $("#txtTel").val(), 
                                        txtConsulta: $("#txtConsulta").val() },                                         
                                        function (response) {
                                        r=response+'';                                         
                                        var f=$('#pEnvioCorreo'); 
                                        if (r == '0'){
                        f.css("display",'block');
                    } 
                                        else if (r == '1'){
                        f.css("display",'block');
                                            f.innerHTML='Error en el envio';
                    }
                                        else { 
                        f.innerHTML='Verifique los campos obligatorios';
                    }                                        
       });
           return false;
           //post 

        })//click    


    });//ready

</script>

When the submit is performed I then catch the form fields on the Load event (No IsPostback veryfing) of the page and write an output accordingly to the response, I end it and then I catch the value to let one thing or other happen on the client.

My attempt to use the ajax method goes like this:

     //metodo 2
     $.ajax({
            type: "POST",
            url: "contacto.aspx",             
            contentType: "application/json; charset=utf-8",
            data:  {   
            txtRaz: $("#txtRaz").val(), 
            txtDir: $("#txtDir").val(), 
            txtEmail: $("#txtEmail").val(), 
            txtTel: $("#txtTel").val(), 
            txtConsulta: $("#txtConsulta").val() 
    },               
            dataType: "json",
            success: function(response) {
            r=response+'';                                         
                                        var f=$('#pEnvioCorreo'); 
                                        if (r == '0'){
                        f.css("display",'block');
                    } 
                                        else if (r == '1'){
                        f.css("display",'block');
                                            f.innerHTML='Error en el envio';
                    }
                                        else { 
                        f.innerHTML='Verifique los campos obligatorios';
                    }        
            }
        });
  //fin metodo 2

This is not working as I am getting my form submited refreshing the whole page which is not what I want.

Could you please give me an insight on this? and/or Is there a better way to do this?.

Thanks for your help.


I made it work and I post this for future reference:

The $.post method works as I explained above.

The $.ajax method wasn’t working for me because I had the data parameter malformed.

Two ways to do it correctly:

1) Setting a correct syntax for the data parameter, please note the following format for data

data:"{'hdT': '" + $("#hdT").val() + "','txtRaz': '" + $("#txtRaz").val() + "','txtEmail': '" + $("#txtEmail").val() + "','txtTel': '" + $("#txtTel").val() + "','txtConsulta': '" + $("#txtConsulta").val() + "'}"

2) Using the JSON plugin to convert the data: parameter information into JSON format:

var thing={hdT: $("#hdT").val(),txtRaz: $("#txtRaz").val(),txtEmail: $("#txtEmail").val(),txtTel: $("#txtTel").val(),txtConsulta: $("#txtConsulta").val()};

And the data information should be passed for the parameter like this:

data: $.toJSON(thing)

Once this is done a PageMethod should be set on the codebehind and no ScriptManager reference is needed because jquery handles all the process.

To pass the information comming from the data object to the PageMethod each property must be a parameter of the Method.

<WebMethod()> _
Public Shared Function ProcesaEnvio(ByVal txtRaz As String) As String

        Return "Returns:" & txtRaz

End Function

Once there the needed process can be achieved.

  • 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-22T12:59:04+00:00Added an answer on May 22, 2026 at 12:59 pm

    You need to make a webmethod in your code behind and then call it with the jquery ajax. and use the jquery json plugin to make sure your json is nicely formed.

    This is a very good tutorial to how to make webmethods to process ajax form data:

    http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/

    Also have a look at
    JSON plugin for jQuery, which provides simple ways to convert to JSON and back again.

    Hope this helps.

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

Sidebar

Related Questions

Hello guys I'm stucked in a point and I need your help. I want
Hello guys! I have been trying to create a if/else statement code in jQuery
Hello guys i'm facing a isolated exception when trying to edit my UI it
Hello guys. I think it isn't possible just using PHP, but just to be
hello guys I am trying to extract all the anchor links from aol but
Hello guys can anyone help me with the issue im having with installation of
Hello Guys, I was just trying to create a plugin, and I needed it
Hello everyone i need some help. I'm trying to make an application for mac
Hello guys I have a confusing question! If I'm using WCF to create a
I am trying to use ExtJS with Asp.Net MVC, and it is going fine

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.