如何在ASP.NET应用程序后面的客户端Javascript和C#代码之间传递数据? [英] How should data be passed between client-side Javascript and C# code behind an ASP.NET app?

查看:55
本文介绍了如何在ASP.NET应用程序后面的客户端Javascript和C#代码之间传递数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在ASP.NET应用程序后面的客户端Javascript代码和C#代码之间传递数据的最有效/标准方法。

在我的项目中,按钮点击事件我有不同的功能,我有一个要求,其中一个加载器正在生成,并且加载器的文本在按钮单击事件中执行的不同功能中更改。

例如我的按钮点击事件

1.第一个函数是保存数据,所以加载器的文本应该是保存数据

2.第二个函数是检索信息,所以现在同一个加载器的文本应该是检索信息。另外一个功能。



我正在使用标签控件并在每个函数调用中分配该标签值,并在我的javascript中我指定标签值加载程序文本。



但它根本不起作用,文本值不交换。



我的javascript加载器功能是这样的:



I'm looking for the most efficient / standard way of passing data between client-side Javascript code and C# code behind an ASP.NET application.
In my project, on button click event i have different function and i have an requirement where a loader is generating and the text of the loader change in different function that is executing in button click event.
e.g in my button click event
1.first function is saving the data,so the text of the loader should be "Saving Data"
2.Second function is retrieving information,so now the text of the same loader should be "Retrieving Information". and so on for another funtion.

for that i am using a label control and assigning that label value in every function call,and in my javascript i am assigning label value into loader Text.

but it is not working at all,text value is not exchange.

my javascript loader function is like this:

$(function () {

        var current_effect = 'win8';

        $('#btnSubmit').click(function () {
            var message = $("#<%=lblMessage.ClientID%>").text();
            run_waitMe(current_effect, message);
        });
function run_waitMe(effect, message) {
            $('body').waitMe({
                effect: effect,
                text: message,
                bg: 'rgba(255,255,255,0.7)',
                color: 'red'
            });
        }

    });





和代码背后我分配不同的标签价值按钮点击事件中的功能。





and in code behind i am assigning label value in different function in button click event.

protected void btnSubmit_Click(object sender, EventArgs e)
    {   

 void function1()
       {
        lblMessage.text="text1";
         .........
       }
 void function2()
       {
        lblMessage.text="text1";
        ........
       }
    }





请帮助我,克服这种情况或任何其他解决方案来满足要求。



Please help me,to overcome from this situation or any other solution to do the requirement.

推荐答案

function (){

var current_effect = ' win8 ';
(function () { var current_effect = 'win8';


' #btnSubmit' ).click( function (){
var message =
('#btnSubmit').click(function () { var message =


#<%= lblMessage.ClientID%>)。text( );
run_waitMe(current_effect,message);
});
function run_waitMe(效果,消息){
("#<%=lblMessage.ClientID%>").text(); run_waitMe(current_effect, message); }); function run_waitMe(effect, message) {


这篇关于如何在ASP.NET应用程序后面的客户端Javascript和C#代码之间传递数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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