内容页面上的javascript [英] javascript on content page

查看:59
本文介绍了内容页面上的javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问底部代码中box5(TextBox)的值,并在javascript附加文件中修改其文本.
但是我做不到.我不能访问box5的值.我怎么能?
谢谢您的帮助.

i wanna to access value of box5(TextBox) in bottom code and modify its text in javascript attached file.
but i cant do it.i cant access value of box5.how i can??
thank ur help.

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server" >
        <asp:TextBox id="box5" runat="server">

推荐答案

您正在使用javascript访问服务器控件.
因此,您需要通过ClientID识别文本框,因为在以纯html呈现ID后,其ID会发生变化.

You are accessing the server control in javascript.
So, you need to identify the textbox through ClientID as the id is changed after it renders in plain html.

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



希望这会有所帮助.
欢呼



Hope this helps.
cheers


由于JavaScript保存在一个单独的文件中,因此您在调用它时必须将<%= box5.ClientId%>传递给该函数. runat="Server"控件的属性ID只能在Code-Behind中使用.

问候,

—曼弗雷德(Manfred)
Since the JavaScript is kept in a separate file, you''ll have to pass the <%= box5.ClientId%> to the function when you are calling it. The attribute ID of a runat="Server" control can only be used from Code-Behind.

Regards,

— Manfred


这篇关于内容页面上的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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