单击clientclick上的asp:botton时清除asp:textbox [英] Clearing asp:textbox when click asp:botton on clientclick

查看:42
本文介绍了单击clientclick上的asp:botton时清除asp:textbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在asp.net页面中,我们有一个文本框(asp:textbox)和一个按钮(asp:button type = image).
在按钮的OnClientClick上调用了以下javascript函数.

Hi,

We''ve one text box (asp:textbox) and a button (asp:button type=image) in asp.net page.
The below javascript function has been called on OnClientClick of the button.

document.getElementById("txtID").value="";





or

document.getElementById("<%=txtID.ClientID%>").value="";



这样会清除文本框中的值,但是回发时,文本框中的值不会被清除.

当我在诸如like之类的代码后面进行验证时,



This results in it clearing the value in text box, but, when post back, the value of the text box it not cleared.

When I validate in code behind like;

If(txtID.Text <> "")
{
   .....
}


它执行if语句中的行.

我们正在使用VS 2008,.Net Framework 2.0,并且控件位于更新面板中.

如果有人有主意,请帮助我们解决此问题.

谢谢,
Rishi


it executes the lines inside the if statement.

We are using VS 2008, .Net Framework 2.0 and the controls are placed inside update panel.

If anybody have an idea please help us to overcome this issue.

Thanks,
Rishi

推荐答案

为更新面板添加触发器(尝试一次)

Add trigger for Update Panel (try it once)

<ajax:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
-- Your Content Here.
</ContentTemplate>
<Triggers><ajax:AsyncPostBackTrigger ControlID="btnId" </Triggers>
</ajax:UpdatePanel>





如果您使用的是Ajax控件,为什么要回发?
该屏幕上有上传功能吗?

请执行以下操作.
1.将按钮ID作为触发器添加到更新"面板.
2.将ChildTriggers属性设置为True.


问候,
基兰.
Hi,


If you are using Ajax controls, why it is going to postback?
Is there any upload functionality in that screen?

Do the following thing.
1.Add the button id to Update panel as Triggers.
2.Enable ChildTriggers property as True.


Regards,
Kiran.


这篇关于单击clientclick上的asp:botton时清除asp:textbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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