链接按钮每次回发后名称都会更改 [英] Link button Name changing after every post back

查看:93
本文介绍了链接按钮每次回发后名称都会更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据列表来保存问题,





我正在使用链接按钮和asp按钮datalist,但每当我点击我的asp按钮时,我的链接按钮文字就会发生变化。





添加问题后我正在设置我的;墨水按钮名称从'添加'中删除'(在客户端)使用javascript)



但是如果我点击我的asp按钮我的链接按钮被重置为'添加'

I'm using a data list to save questions ,


I'm using a link button and a asp button in datalist , but whenever i click my asp button my link button text is getting changed .


after adding a question I'm setting my l;ink button name to 'remove' from 'add' (in client side using javascript)

But if i click my asp button my link button is getting reset to 'add'

推荐答案

如果你使用4.0并使其保持静态,则使用clientidmode。
use clientidmode if you are using 4.0 and keep it static.


尝试从服务器端为linkbutton设置文本。

Try setting text for linkbutton from serverside.
lbtn.Text="remove";


您是否尝试更新更新面板中的标签文字?

您可以尝试以下代码。

Are you trying to update label text which is in update panel?
Can you try the below code.
<asp:Label runat="server" Text="salam" ID="lbl" ></asp:Label>
<asp:HiddenField id="hdlbl" runat="server" />
document.getElementById("lbl").InnerHTML = "10"; // update client side
document.getElementById("hdlbl").value = "10";





在页面加载中添加以下代码



if(Page.IsPostBack)

{

lbl.Text = hdlbl.value;

}



Add the following code in page load

if(Page.IsPostBack)
{
lbl.Text = hdlbl.value;
}


这篇关于链接按钮每次回发后名称都会更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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