清除更新面板中的文本框控件 [英] Clear the textbox controls within the update panel

查看:64
本文介绍了清除更新面板中的文本框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的网页有母版页。我也使用更新面板。我使用以下方法清除文本框。



Hi,

My webpage has master page. Im using update panel also. I clear the textbox using following method.

ContentPlaceHolder content = pageControl.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
 cl = pageControl.Master.FindControl("ContentPlaceHolder1");
  
                foreach (Control ct in cl.Controls)
                {
                    if (ControlType.TextBox == controlName)
                    {
                        string gtype=ct.GetType().ToString();
                        if (ct.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                           pageControl.Master.FindControl("ContentPlaceHolder1"); = string.Empty;
                    }
}





它没有更新面板。但是在更新面板中,它无效。没有错误来。它执行这个编码。但文本框未被清除。



It is working without update panel. But in Update panel it is not working. No error come. It is execute this coding. But the textbox is not cleared.

推荐答案

试试这个,



如果UpdateMode属性设置为有条件的

您调用UpdatePanel的Update方法(UpdatePanel.UpdateMode()属性。)
Try this,

If the UpdateMode property is set to Conditional
You call the Update method(UpdatePanel.UpdateMode() Property) of the UpdatePanel.


代码将帮助您解决问题



following Code will help you to come out from your problem

IEnumerable<TextBox> textBoxes = panel.Controls.GetChildControls().OfType<TextBox>();
foreach (TextBox tb in textBoxes)
{
    tb.Text = "";
}


这篇关于清除更新面板中的文本框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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