使用jquery和C#将客户端值发送到服务器端 [英] Sending client side value to server side with jquery and C#

查看:56
本文介绍了使用jquery和C#将客户端值发送到服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个jQuery插件,该插件为我提供了一个包含链接列表的弹出窗口.当我单击链接时,它将通过jquery更改文本框的值:

I''m using a jquery plugin that give me a popup with a list of links. When I click the link it changes the value of a text box via jquery:

$(document).ready(function () {
            $("a.clickable").click(function (event) {
                event.preventDefault();
                $("input#new_casecontactid").val($(this).attr('data-fullname'));
            });
        });


这部分工作正常,但是当我保存表单时,服务器端仍然认为旧值仍在文本框中.


This part works fine, but when I save the form, the server side still thinks the old value is still in the textbox.

protected void btnSv_Click(object sender, EventArgs e)
{
    var ContactName = fullname.Text
}


如何从客户端到服务器端获取文本框的新值?





这是我用来使其正常工作的内容:


How do I get the new value of my textbox from the client side to server side?





This is what I used to get it working:

$(document).ready(function () {
     $("a.clickable").click(function (event) {
         event.preventDefault();
         txt = $(this).attr('data-fullname');

         $.ajax({
             type: "POST",
             data: txt,
             success: function () {
                 $("input#new_casecontactid").val(txt);
             }
         });
     });
 });

推荐答案

(文档).ready(功能(){
(document).ready(function () {


(" ).click(功能(事件){ event.preventDefault();
("a.clickable").click(function (event) { event.preventDefault();


(" ).val(


这篇关于使用jquery和C#将客户端值发送到服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆