查找html textrarea表单母版页 [英] find html textrarea form master page

查看:90
本文介绍了查找html textrarea表单母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个母版页,上面有一个按钮,还有一个名为default.aspx的内容页.在default.aspx中,我已经放置了html textarea.现在,当我单击放置在masetr页面上的按钮时,应该更改textarea的值.我已经做了很多努力,但每次都徒劳无功.请任何人可以帮助我吗?在此先感谢....

i have master page and have a button on it, and also i have a contentpage named default.aspx . in default.aspx i have placed html textarea. Now When i click on the button placed on the masetr page, the value of the textarea should be change. I have tried lot of efforts but every time it is in vain. Please any one can help me out? Thanks in advance....

推荐答案

首先,如果要在服务器端访问html控件,则必须在其中添加runat=server.

试试:
First of all, if you want a html control to access on server side, you have to add runat=server to it.

Try:
// Gets a reference to a TextBox control inside
 // a ContentPlaceHolder
 ContentPlaceHolder mpContentPlaceHolder;
 HtmlTextArea mpTextBox;
 mpContentPlaceHolder =
   (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
 if(mpContentPlaceHolder != null)
 {
     mpTextBox =
         (HtmlTextArea) mpContentPlaceHolder.FindControl("TextArea1");
     if(mpTextBox != null)
     {
         // Do your stuff
         mpTextBox.Value = "TextBox found!";
     }
 }



此处的详细信息: MSDN:如何:参考ASP.NET母版页内容 [ ^ ]



Details here: MSDN: How to: Reference ASP.NET Master Page Content[^]


这篇关于查找html textrarea表单母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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