.net aspx页面通过js获取不到input类型的值

brilyrose 2013-07-25 10:12:11
为什么js里的title获取不到Title1的值 ?
一、js部分
function getValues() {

// 取得HTML内容

var html = editor.html();

// 同步数据后可以直接取得textarea的value

editor.sync();

html = document.getElementById('content1').value; // 原生API
var title = document.getElementById("Title1").value;
var flag = CreateNews.insertNews(html,title);
if (flag == "1") {
alert("新闻插入成功!");
}else{
alert("新闻插入失败!");
}

}
二、页面部分
<table id="tb1" width="100%">
<tr align="center">
<td align="right" width="10%">标题:</td>
<td><input id="Title1" name="Title1" style="width:100%" type="text" runat="server" />

</td>
</tr>

<tr align="center"><td colspan="2" align="center">
<%--textbox id="content1" name="content" cols="100" rows="8" style="width: 700px; height: 300px;"></textbox--%>
<textarea id="content1" name="content" cols="100" rows="8" style="width: 700px; height: 300px;">

</textarea>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"> </asp:ScriptManager>

</td>
</tr>
<tr align="center"><td colspan="2"><input type="button" onclick="getValues()" value="提交" /></td></tr>
</table>


...全文
150 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
brilyrose 2013-08-05
  • 打赏
  • 举报
回复
已找到答案了,使用母版页id的原因

4,818

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧