在标签中显示变量值 [英] display a variables value in a label

查看:97
本文介绍了在标签中显示变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#在asp.net中的标签中显示变量值?

How do I display a variables value in a label in asp.net using C#?

推荐答案

就像那样...



假设您的标签ID类似于lbltest,您的varialbe是整数类型,其别名是abc,因此您可以像这样显示其值...





just like that...

suppose your lable id is like lbltest and your varialbe is type of integer and its alias is abc so you can display its value like this...


int abc = 10;
lbltest.Text = abc.ToString();


您可以在客户端和服务器端显示变量



在客户端使用类似的javascript ..



You can display variable at Client side and Server side as well

At Client side using javascript like that..

var i = 123;

 document.getElementById(lblID).innerHTML = i;





在服务器端代码后面就像那样...





At Server side in code behind like that...

string ValueString = "My Name Is Nirav";

 lblID.Text = ValueString;


这篇关于在标签中显示变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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