使用Javascript重置ASPX中的ASCX [英] Reset ASCX in ASPX using Javascript

查看:51
本文介绍了使用Javascript重置ASPX中的ASCX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个具有4个文本框,2个下拉菜单,2个复选框和2个单选按钮的ascx控件.我已将此控件添加到我的aspx页面.

我的ASPX页面有两个按钮,保存和重置.

我想使用JavaScript重置aspx页面中所有ascx控件.但是我收到一条错误消息,指出无法找到控件.

我使用的JavaScript如下:

Hi,
I have a ascx control having 4 textboxes, 2 dropdowns, 2 check boxes and 2 radio buttons. I have added this control to my aspx page.

My ASPX page has two buttons Save and Reset.

I want to reset all the controls of ascx in aspx page using javascript. But I get an error stating unable to find the control.

The javascript used by me as follows:

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



请帮忙.

预先感谢.



Please help.

Thanks in advance.

推荐答案



如果您没有使用JavaScript重置UserControl中的控件的约束,则可以使用委托在UserControl中调用Reset方法.

希望您对代理 [ [
Hi,

If you do not have constraint to use javascript to reset your controls in UserControl then you can use delegate to call the Reset method in the UserControl.

Hope you have idea about Delegate[^]

Thanks
-Amit Gajjar




据我了解,在您的javascript中,首先在页面中找到Usercontrol实例,然后在usercontrol中找到文本框.

这就是我在aspx.cs中所做的.在javascript中也应该是相同的.
我在aspx页面的选项卡面板中有一个用户控件.

Hi,

As per my understanding , in your javascript first find the Usercontrol instance in your page and then find the text box in your usercontrol.

This is how i did in my aspx.cs.Should be the same in javascript as well.
i have a usercontrol in a tab panel in my aspx page.

 UserControl ucname = new UserControl();
 ucname = tabPnlUser.FindControl("User") as UserControl;
TextBox txtucFirstName = (TextBox)ucname.FindControl("txtFirstName");
 txtucFirstName.Text = "";




希望这会有所帮助.




Hope this helps.


这篇关于使用Javascript重置ASPX中的ASCX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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