/    Sign up×
Community /Pin to ProfileBookmark

Need Help with Jquery, Ajax and C#

Hi

I am using C# and asp.net with Jquery. I am trying to use Jquery for ajax and as my javascript framework. I am not using the script manager nor do I
plan too.

I am just trying to learn how to do ajax and talk back and forth to the server.

I am finding this very hard to do.

All I am trying to do is this:

  • 1. Have a html sumbit button.

  • 2. When the submit button is clicked an ajax event is fired. In this ajax event a hardcoded value gets sent to the server.

  • 3. The server grabs that hardcoded value and print it out back to the screen.
  • I been trying and trying and I can’t get it to work

    I tried to do this:

    [code]
    <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

    <html xmlns=”http://www.w3.org/1999/xhtml”>
    <head runat=”server”>
    <title></title>

    <script src=”jquery-1.2.6.js” type=”text/javascript”></script>

    <script src=”jquery.form.js” type=”text/javascript”></script>

    <script type=”text/javascript”>

    $(function()
    {
    $(“#submit”).submit(function()
    {
    $.post(“Default.aspx”, { name: “testagaga” });
    });
    });

    </script>

    </head>
    <body>
    <form id=”form1″ runat=”server” >
    <input value=”adaga” type=”text” id=”mytext”/>
    <input type=”submit” id=”submit” />
    </form>

    </body>
    </html>

    [/code]
    [code]
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    if (IsPostBack == true)
    {

    string test = Request[“name”];
    }
    }
    }

    [/code]

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @chobo2 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...