设置ASP文字文本使用Javascript [英] Set ASP Literal text with Javascript
本文介绍了设置ASP文字文本使用Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个asp:我的网页上的文字(不能被转换为标签或任何其它控制),我需要改变通过JavaScript的文本。我有以下的code,对于一个的标签的工作。任何人可以帮助?
<脚本类型=文/ JavaScript的>
功能changeText(){
的document.getElementById('<%= Test.ClientID%GT;')。innerHTML的=新文本;
}
< / SCRIPT> < A HREF =#的onclick ='changeText()'>改变文字< / A>
< ASP:标签ID =测试=服务器文本=原始文本/>
谢谢
更新:
我无法从字面更改为code背后写HTML / CSS给它的信息消息例如:
LITMessage.Text =< DIV CLASS ='成功'>信息更新成功< / DIV>中
解决方案
< ASP:文字>
控件不会创建自己的HTML标记结果
因此,不存在元件可以操作
< DIV&GT:; 相反,你可以包装&LT ASP ID。
I have an asp:Literal on my page (which cannot be converted to a Label or any other control) that I need to change the text of via JavaScript. I have the following code that works for a Label. Can anybody help?
<script type="text/javascript">
function changeText() {
document.getElementById('<%= Test.ClientID %>').innerHTML = 'New Text';
}
</script>
<a href="#" onclick='changeText()'>Change Text</a>
<asp:Label id="Test" runat="server" Text="Original Text" />
Thanks
UPDATE:
I cannot change from a literal as the code behind writes HTML/CSS to it for an Information Message e.g:LITMessage.Text = "<div class='success'>Information Successfully Updated</div>"
解决方案 <asp:Literal>
controls don't create their own HTML tag.
Therefore, there is no element that you can manipulate.
Instead, you can wrap the <asp:Literal>
in a <div>
tag with an ID.
这篇关于设置ASP文字文本使用Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文