Rectangle 27 17

I've use following way and for me work 100% properly:

the first i create a function and write my jquery function in to the function in the my page:

<script>
    function myFunction(params) {
        $.my_jquery(params...)
        ......
    }
</script>

then i used this code in event handler of my control(for example click a button) who my control is inside a update panel:

protected void myButton(object sender, EventArgs e)
{
    .....
    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>myFunction(params...);</script>", false);
}

Call JQuery function from code behind (aside) ASP.Net and C# - Stack O...

asp.net jquery ajax updatepanel
Rectangle 27 5

Sounds like you need a button that has a client-side action instead of one that posts back.

<asp:Button ID="Clickable" runat="server" text="Click me" OnClientClick="JavascriptCall();" />

Additionally, while jQuery is generally backward compatible, it's not a good idea to reference jQuery's latest .js file directly. Instead I would download a version of it that you want, and place it statically on your site for direct reference of a known version. It is not good to add a dependency on the state or availability of a resource on an external site when not necessary.

@ballance i would split that last statement in half, agree with the first part and not the second - not good to add reference to an external source that will always change, but can significantly increase load speed to outsource the hosting of static scripts like that

@rexm On the small scale you are correct that it would increase performance, but it would still be better to reference a static version of the resource, even if jQuery's site hosts it. For bigger projects I would say just add a separate hostname for your static resources. (via @rexm Lunch 'n Learn)

Call JQuery function from code behind (aside) ASP.Net and C# - Stack O...

asp.net jquery ajax updatepanel
Rectangle 27 1

Actually yes, part of the solution is to call directly the javascript function, but instead of using a client-side control I called the Javascript once my UpdatePanel request is over as is explained in the following blog:

<link type="text/css" rel="stylesheet" href="css/ui.all.css" />

    <script type="text/javascript" src="jquery-latest.js"></script>

    <script type="text/javascript" src="ui.core.js"></script>

    <script type="text/javascript" src="ui.tabs.js"></script>

    <script type="text/javascript">

    //enable tabs if a deal is selcted or saved.
    function EndRequestHandler(sender, args) {
        var rec_id = document.getElementById('<%=hidden_value.UniqueID %>').value;

        if (rec_id=="")
            hidetabs();
        else
            showtabs();
    }

    hidetabs();

    $(document).ready(function(){
        $("#rec_entry").tabs();
    });

    function hidetabs(){
        $(document).ready(function(){
        $("#rec_entry").tabs();
        $('#rec_entry').data('disabled.tabs', [1, 2, 3, 4, 5]);});
    }

    function showtabs(){
        $(document).ready(function(){
        $("#rec_entry").tabs();
        $('#rec_entry').data('disabled.tabs', []);});
    }

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

    </script>

    ...html code add the tabs...
.... code to save the new record ........  

        UpdatePanel_mypanel.Update();
    }

after the panel is updated the EndRequestHandler evalues a flag (in this case a hiddenfield) and calls the Javascript function that enable or disable the tabs.

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

I followed your advice of including the javascript files into my project. Thanks again!

Call JQuery function from code behind (aside) ASP.Net and C# - Stack O...

asp.net jquery ajax updatepanel
Rectangle 27 1

protected void myButton(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>myFunction(params...);</script>", false);
}

c# - Call jquery button click event from code behind - Stack Overflow

c# jquery asp.net c#-4.0
Rectangle 27 3

In your imageProcess.aspx.cs create a webmethod like:

[WebMethod]
public static string YourMethod(your parameters)
{
//Do Your Work
}

and in your dashboard page, in javascript use jquery to send request your webmethod like:

$.ajax({
type: "POST",
    url: "imageProcess.aspx/YourMethod",
    data: "{parameter1Name:'" + JSON.stringify(parameter1value) + "', Parameter2Name:'" + JSON.stringify(parmeter2Value) + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data) {
// do your success work, keep in mind that your returned data will be in data.d
    },
error: function(XMLHttpRequest, textStatus, errorThrown) {
// do your failuer work
}
});
asp:panels
dashboard.aspx

If you mean to say that panels are on dashboard.aspx and you want to access them in javascript on dashboard.aspx, i will say yes you can access them.

I mean that I want to access them in the imageProcess.aspx code behind, because I need to append html code to them that I generate server-side.

You won't be able to access them over in imageProcess.aspx, however from above method you can return the data or html and append that while staying in Dashboard.aspx

c# - Calling a function in the .aspx.cs code behind file with jQuery l...

c# jquery asp.net .net code-behind
Rectangle 27 1

Code Behind (in C# but easily convertible to VB.NET):

[WebMethod]
public static string SayHello(string name)
{
    return "Hello " + name;
}
$("#btnTest").click(function() {
    PageMethods.SayHello("Test", function(result) {
      alert(result);  // Should show "Hello Test"
    });
});

Thanks, but I'm still getting HTML back. I used the same format. Is there something else I'm missing?

jquery - Call ASP.NET WebMethod using AJAX JSON - Stack Overflow

jquery asp.net ajax json vb.net
Rectangle 27 3

You could use a PageMethod. Let's take an example of such a method in your code behind:

[WebMethod]
public static string MyMethod(string memId)
{
    return string.Format("Thanks for calling me with id: " + memId);
}

Things to note: the method must be static and decorated with the [WebMethod] attribute.

And on the client side you could invoke this method using the jQuery.ajax() function like this:

$.ajax({ 
    url: 'default.aspx/MyMethod',
    type: 'POST', 
    contentType: 'application/json; charset=utf-8',
    data: JSON.stringify({ memID : mem_ID }),
    success: function (result) { 
        alert(result.d);
    } 
});

Also the error you are getting about the undefined $ symbol is related to the fact that you didn't reference the jQuery library in your page. So make sure that in your WebForm you have actually added reference to the jQuery library before using it. For example:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>

Error 2 The type or namespace name 'WebMethod' could not be found (are you missing a using directive or an assembly reference?)

Shift+Alt+F10+Enter while hovering over the [WebMethod] attribute will add the correct using directive to the top of your code behind: using System.Web.Services;. Also make sure that the System.Web.Services.dll assembly is referenced in your project. Please read the documentation: msdn.microsoft.com/en-us/library/

@MarkSchultheiss, that's no longer necessary with HTML5. But I have added it for people still using HTML 4. Take a look here: stackoverflow.com/a/4195441/29407

Dude, that was a typo on my side, it should be string.Format with capital F. I have updated my answer. I guess you should take some basic C# getting started tutorial as those are some really, really basic things you should learn before even getting into ASP.NET.

javascript - ajax client-to-server side - Stack Overflow

javascript asp.net ajax
Rectangle 27 6

You can use a hiddenfield server control assign the values you need to it in javascript and assess it on server side. If you do not want post back then you can use jQuery ajax to send values.

<asp:hiddenfield id="ValueHiddenField" runat="server"/>
document.getElementById('ValueHiddenField').value = "yourValue";
string yourValue = ValueHiddenField.Value;

Using jQuery ajax and web method to send values to code behind, you can find nice tutorial over here.

$.ajax({
  type: "POST",
  url: "PageName.aspx/MethodName",
  data: {'yourParam': '123'},
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
    // Do something interesting here.
  }
});
[WebMethod]
public static void YourMethod(string yourParam)
{
   //your code goes here
}

And what mechanism gets you to the code-behind?

You need to do post back, or you can use jQuery ajax call to send values.

I think the OP is trying to avoid doing a postback, because otherwise I think they would have added a server control to the page, but I may be wrong.

How to get javascript values on code behind in c# - Stack Overflow

c# javascript jquery asp.net ajax
Rectangle 27 1

You can call a JavaScript function using registerStartupScript.

<script type="text/javascript">

   function printOutput(arg) {            
      alert(arg);
   }

</script>
protected void DoSomethingButton_Click(object sender, EventArgs e)
{
   ClientScriptManager cs = Page.ClientScript;

   cs.RegisterStartupScript(typeof (Page), "PrintScript_" + UniqueID, "printOutput('My HTML Code Generated by jquery function');", true);
}

How to call JavaScript/jQuery function from .cs file (C#) - Stack Over...

c# javascript jquery .net asp.net
Rectangle 27 1

I would investigate the use of ASP.NET AJAX Page Methods, because they allow for script callable stand-alone web services that live in an .aspx page, like this:

Page Method in your code-behind file (call it default.aspx for discussion's sake):

[WebMethod]
public static string SaveData(string name, string uid)
{
    // Logic here to do what you want with name and uid values (i.e. save to database, call another service, etc.)
}
$.ajax({
    type: "POST",
    url: "default.aspx/SaveData",
    data: "{'name':'John', 'uid':'ABC123'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {
        // Do something interesting here.
    }
});

Notes: ASP.NET AJAX Page Methods automatically encode their response to JSON so you will not see any JSON serialization in the code-behind or any serialization logic at all.

@KAarl i have edit and post my full code now tell me how i can use ajax posting in existing code ..Thanks

What client-side event do you want to trigger the passing of name and UID values to the C# code-behind on the server?

well it depends upon what you are doing with the name and UID on the server, I think you need to explain more clearly what you are trying to accomplish with this data in the code-behind.

i have to save facebook user information in database fields.Right now i am getting information in javascript.you can check.

How to get javascript values on code behind in c# - Stack Overflow

c# javascript jquery asp.net ajax
Rectangle 27 13

The solution is not so simple. You must have the ability to call the original callback function after pressing the Ok button of jQuery UI Dialog.

First you need a generalized js function for showing the dialog:

function showConfirmRequest(callBackFunction, title, content) 
{
    $("#divConfirm").html(content).dialog({
        autoOpen: true,
        modal: true, 
        title: title,
        draggable: true,
        resizable: false,
        close: function(event, ui) { $(this).dialog("destroy"); },
        buttons: { 
            'Ok': function() { callBackFunction(); },
            'Cancel': function() {
                $(this).dialog("destroy");
            }
        },
        overlay: { 
            opacity: 0.45, 
            background: "black" 
        } 
    });
}

I supposed the presence of a div like

<div id="divConfirm"></div>

On c# code-behind you have to register the previous client function, passing the original asp.net callbackFunction of your control as parameter (I generalized):

protected void AddConfirmRequest(WebControl control, string title, string message) 
{
    string postBackReference = Page.ClientScript.GetPostBackEventReference(control, String.Empty);
    string function = String.Format("javascript:showConfirmRequest(function() {{ {0} }}, '{1}', '{2}'); return false;", 
                                     postBackReference,
                                     title,
                                     message);
    control.Attributes.Add("onclick", function);
}

Through the method GetPostBackEventReference you have the ability to retrieve the postback function that asp.net assign to the control.

Now, on Repeater ItemDataBound, retrieve the control that execute the delete and pass it to this function:

<asp:Repeater ID="repeater" runat="server" OnItemDataBound="repeater_OnItemDataBound">
    ...
    <ItemTemplate>
        ...
        <asp:Button ID="btnDelete" runat="server" Text="Delete" />
        ...
    </ItemTemplate>
</asp:Repeater>

and the code:

protected void repeater_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        WebControl btnDelete = ((WebControl)e.Item.FindControl("btnDelete"));
        AddConfirmRequest(btnDelete, "Confirm delete", "Are you sure? Really???");
    }
}

Thank you, I've tried to generalize much possible. I'm working on put the solution on a custom control, overriding the actual asp:Button

post it somewhere when you done,and let here a note!

Great code and example. I would like to confirm that I used this and it is working well. Thank-you!

javascript - JQuery DIalog and ASP.NET Repeater - Stack Overflow

asp.net javascript jquery
Rectangle 27 2

In the end it is all html, javascript and css. Javascript in PF is mainly jquery and all components have javascript code behind them to function on the client side.

There are several ways to plug into this. Attaching plain jquery event handlers to the right element (checkable via your browser developer tool and/or checking what the PrimeFaces javascript does) is an option, but you have to reapply them over and over again when e.g. ajax calls take place. Another option is to override the basic menu button functionality without changing the PF original source.

Since the code is open source, you can try to find the javascript source of the PrimeFaces MenuButton. It is in this case all defined in menu.js and this can be fairly easily looked at (and is cleanly written)

In there you can see all events that are added to the component and also if there e.g. are onBeforeShow handlers or not (some components in PrimeFaces have those, the MenuButton not which is unfortunate for you, but I've not seen a usecase like this up to now).

The downside of overriding the basic functionality unfortunatly is that this will then be true for all menu buttons. So you have to implement some logic to decide if you actually need to perform some custom action or not. There are several ways to do that, but the easiest in my opinion is to check for the presence of a specific style class (e.g. 'stopPoll').

var oldPFShow = PrimeFaces.widget.MenuButton.prototype.show
PrimeFaces.widget.MenuButton.prototype.show = function() {
  alert("before show");
  oldPFShow.apply(this, arguments);
}

var oldPFHide = PrimeFaces.widget.MenuButton.prototype.hide
PrimeFaces.widget.MenuButton.prototype.hide = function() {
  oldPFHide.apply(this, arguments);
  alert("after hide");
}

(do not forget to call the original functions)

Where I put the alerts, you have to implement checking for the presence of a class or leave that out if you have one menu button on that page or want the behaviour for all menubuttons

Some general comments: (Will be removed later on, but difficult to format in the comments)

Part of the problem is that I do not know how to identify the JSF component uniquely from javascript,

This is a generic PrimeFaces thing (and differs from component sets). Apply a widgetVar attribute and with PF('') you have a handle to the specific components.

And as you can see the explicit fact that you use a PrimeFaces menuButton is of the highest importance. Having a small piece of code (smaller then you have now, but compliments for the mcve) is confirmation of this (assumption is the mother of all... ) Adding 'javascript' as a very generic tag, often attracts the 'wrong' people, as does 'java' So please next time leave those out

We've changed to code as suggested by performing the override. Initially we called the override in @(document).ready, but we found that at some point in time, the client Javascript code is replaced by the original. We then hooked the call onto ajaxStatus. This too worked for a while but stopped working after a while (MenuButton javascript (all isolated to a single file) seemed to be replaced). Now to find an event in which one can reliably perform the override...

Just include it like normal javascript. No need to load it each time then. Just make sure it is loaded AFTER primefaces.js

jsf - React to a MenuButton being clicked - Stack Overflow

jsf primefaces
Rectangle 27 4

I use this code for cross domain ajax call, I hope it will help more than one here. I'm using Prototype library and you can do the same with JQuery or Dojo or anything else:

Step 1: create a new js file and put this class inside, I called it xss_ajax.js

var WSAjax = Class.create ({
    initialize: function (_url, _callback){
        this.url = _url ;
        this.callback = _callback ;
        this.connect () ;
    },
    connect: function (){
        var script_id = null;
        var script = document.createElement('script');
        script.setAttribute('type', 'text/javascript');
        script.setAttribute('src', this.url);
        script.setAttribute('id', 'xss_ajax_script');

        script_id = document.getElementById('xss_ajax_script');
        if(script_id){
            document.getElementsByTagName('head')[0].removeChild(script_id);
        }

        // Insert <script> into DOM
        document.getElementsByTagName('head')[0].appendChild(script);
    },
    process: function (data){
        this.callback(data) ;
    }

}) ;

This class creates a dynamic script element which src attributes targets your JSON data provider (JSON-P in fact as your distant server must provide the data in this format :: call_back_function(//json_data_here) :: so when the script tag is created your JSON will be directly evaled as a function (we'll talk about passing the callback method name to server on step 2), the main concept behind this is that script like img elements are not concerned by the SOP constraints.

Step2: in any html page where you wanna pull the JSON asynchronously (we call this AJAJ ~ Asynchronous JAvascript + JSON :-) instead of AJAX which use the XHTTPRequest object) do like below

//load Prototype first
//load the file you've created in step1


var xss_crawler = new WSAjax (
     "http://your_json_data_provider_url?callback=xss_crawler.process"
 ,   function (_data){
            // your json data is _data and do whatever you like with it 
        }) ;

D'you remenber the callback on step 1? so we pass it to the server and it will returns the JSON embeded in that method so in our case the server will return an evalable javascript code xss_crawler.process(//the_json_data), remember that xss_crawler is an instance of WSAjax class. The server code depends on you (if it's yours), but most of Ajax data providers let you specify the callback method in parameters like we did. In Ruby on rails I just did

render :json=>MyModel.all(:limit=>10), :callback => params[:callback],:content_type => "application/json"

and that's all, you can now pull data from another domain from your apps (widgets, maps etc), in JSON format only, don't forget.

javascript - AJAX cross domain call - Stack Overflow

javascript jquery ajax json jsonp
Rectangle 27 2

I've been working on the same thing and a friend of mine helped me with this part. This code is in C# but you should be able to port it over.

<script type="text/javascript">
        $(document).ready(function() {
            function renderTable(result) {
                var dtData = [];
                // Data tables requires all data to be stuffed into a generic jagged array, so loop through our
                // typed object and create one.
                $.each(result, function() {
                    dtData.push([
                           this.FirstName,
                           this.LastName,
                           this.Sign
                        ]);
                });

                $('#grid').dataTable({
                    'aaData': dtData,
                    "bJQueryUI": true
                });
            }

            // Make an AJAX call to the PageMethod in the codebehind
            $.ajax({
                url: '<%= Request.Url.AbsolutePath %>/ServerSideTest',
                data: '{}',
                type: 'POST',
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function(result) {
                    // Call the renderTable method that both fills the aaData array with data and initializes the DataTable.
                    renderTable(result.d);
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest + ": " + textStatus + ": " + errorThrown);
                }
            });
        });
    </script>
<table id="grid" width="100%">
        <thead>
            <tr>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Sign</th>
            </tr>
        </thead>

        <tbody>
            <tr>
                <td colspan="5" class="dataTables_empty">Loading data from server</td>
            </tr>
        </tbody>
    </table>
// to serialize JSON in ASP.NET, it requires a class template.
    [Serializable]
    public class Data
    {
        // Yay for 3.5 auto properties
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Sign { get; set; }
    };

    [WebMethod]
    public static List<Data> ServerSideTest()
    {
        List<Data> DataList = new List<Data>();

        Data thisData = new Data();
        thisData.FirstName = "Sol";
        thisData.LastName = "Hawk";
        thisData.Sign = "Aries";

        DataList.Add(thisData);

        Data thisData2 = new Data();
        thisData2.FirstName = "Mako";
        thisData2.LastName = "Shark";
        thisData2.Sign = "Libra";

        DataList.Add(thisData2);

        return DataList;
    }

The next step for me is getting the filtering, paging and sorting working. Let me know if you get these parts working =)

did you ever get the filtering, paging, and sorting to work?

webforms - jQuery DataTables server side processing and ASP.Net - Stac...

jquery-plugins webforms asp.net-2.0 datatables
Rectangle 27 2

While I didn't hide it, I did find another way to get what I wanted. When the color is selected I call a javascript function that gets the color code from the textbox and stores it in a hidden field, then clears the textbox's text, then finally sets the background color of the textbox to the color that was selected.

Here is the aspx code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="color.aspx.cs" Inherits="color" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
    function ColorSelectionChanged() {
        var txtColorPickerSelector = '#' + txtColorPickerID;
        var ColorCodeSelector = '#' + ColorCodeID;
        var colorCode = '#' + $(txtColorPickerSelector).val();
        $(txtColorPickerSelector).val('').css('background-color', colorCode);
        $(ColorCodeSelector).val(colorCode);
    }        
</script>

</head>
<body>
<form id="form1" runat="server">

<asp:HiddenField ID="ColorCode" runat="server" />

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:TextBox ID="txtColorPicker" runat="server" Width="2em"></asp:TextBox>

<cc1:ColorPickerExtender ID="txtColor_ColorPickerExtender" runat="server" 
    TargetControlID="txtColorPicker"
    OnClientColorSelectionChanged="ColorSelectionChanged" />

&nbsp;<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />

<asp:Label ID="lblColorCode" runat="server"></asp:Label>
</form>
</body>
</html>

<script type="text/javascript">
    var txtColorPickerID = '<%=txtColorPicker.ClientID %>';
    var ColorCodeID = '<%=ColorCode.ClientID %>';    
</script>
using System;
using System.Drawing;

public partial class color : System.Web.UI.Page
{
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        lblColorCode.Text = ColorCode.Value;
        txtColorPicker.BackColor = ColorTranslator.FromHtml(ColorCode.Value);
    }
}

I just assign the code to the label to prove that color code is being submitted. Sorry for the aspx formatting. Tested and working in Chrome, IE 6, IE 7, Firefox 3, Opera 9, and Safari 4.

This solution does works, but I am facing one problem. In the initial stage it shows Hexa code. Please help me to resolve this.

.net - Hide Textbox Targeted by the ColorPickerExtender - Stack Overfl...

.net asp.net asp.net-ajax ajaxcontroltoolkit
Rectangle 27 1

Instead of implementing the whole thing, you can use the Asp.Net UpdatePanel to handle partial page rendering for you.

in order to have the content of your UpdatePanel updated every second as you requested, you need to use javascript to call the auto-rendered Asp.Net postback function with the update panel's id as an argument.

here is a full example of a serverside clock:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="UpdatePanel1_Load">
    <ContentTemplate>
        <label id="Label_For_Server_Time" runat="server"></label>
    </ContentTemplate>
</asp:UpdatePanel>

here you can see a label that runs at server so we could access it from code behind;

<script type="text/javascript">
    $(function () {
        setInterval("__doPostBack('<%=UpdatePanel1.ClientID%>', '');", 1000);
    });
</script>

this is the piece of code responsible for updating the updatepanel every second, or rather 1000 milliseconds. the function __doPostBack() is an asp.net generated function and by calling setInterval we are making the updatepanel post back every second. the $(function (){}); wrapper here only meant to keep the code from executing before DOM fully loads. you tagged your question with jQuery, so i assume its fine with you.

in your code behind, you need to add the updatepanel's load handler, which runs when the panel posts back:

protected void UpdatePanel1_Load(object sender, EventArgs e)
{
    Label_For_Server_Time.InnerText = DateTime.Now.ToString();
}

note that in your case, instead of calling a response.write you can dynamically clear your update panel and add HtmlGenericControl in it per 'train', or add them only once and update their styling every postback

<ContentTemplate>
Response.Write
HtmlGenericControl myDiv1 = new HtmlGenericControl("div")
UpdatePanel1.Controls.Add()
myDiv1.Style["margin-left"]=t.XTrainLocation-8

you can clean your panel every time by calling UpdatePanel1.Controls.Clear();

c# - pass list of string to javascript that is sent by asp code behind...

c# javascript jquery asp.net
Rectangle 27 0

in script cs fucnction calling using scriptmanager

[System.Web.Services.WebMethod]
public static string set_single_amount(arg a1)
{
     return value;
}
$("#control").click(function()
{
  PageMethods.set_single_amount(value,afercalling)
});

function afercalling(result)
{
alert(result);
}

jquery - Calling ASP.NET Code Behind function from JavaScript - Stack ...

javascript jquery asp.net
Rectangle 27 0

under text function one more javascript function is calling so i removed that call from text function now its working.

jquery - javascript function not calling from code behind when i'm cal...

javascript jquery asp.net c#-4.0
Rectangle 27 0

you have to assign class / id to the cell that you want to make hidden , and use jQuery or javascript to implement this. you may call this function whereas you need page as well as code behind

$(this).parent().remove();
$(this).remove();

c# - dynamically remove td from table inside gridview - Stack Overflow

c# asp.net .net gridview ado.net
Rectangle 27 0

Correctly you mean you wish to call a server-side routine from client-side code...

I would suggest you force a postback using JavaScript : __doPostback('CodeBehindFunction',iParameter); - Then in the Page Init event of your server side code, catch this custom postback by something like..

if (Request.Params["__EVENTTARGET"] == "CodeBehindFunction")
{
    int i;
    // Try to convert the argument (in the example this is the value of iParameter)
    if (int.TryParse(Request.Params("__EVENTARGUMENT"),out i)
    {
        CodeBehindFunction(i);
    }
}

Alternatively use a WebService called through jQuery.ajax.

I musn't do postback because a lot of callback function in this page

Then you should use a WebService and call with jQuery.ajax

I'm using client callback, Can't I solve by Client callback?

asp.net - Calling code behind function from jquery Side - Stack Overfl...

jquery asp.net