如何获取静态html里input中type=text输入的值
ASPX代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="CoolBlog.register"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title> </title>
<link href="res.css" rel="stylesheet" type="text/css"/>
<script language="javascript" src="res.js" type="text/javascript"></script>
</head>
<body>
<form method="post" action="">
<div id="title" class="divclass">
<ul>
<li>
<div class="mat-table">
<div><input id="yhmid" name="yhmid" type="text" onfocus='xs_yhm("yhmid","pdwk","jsyhm")' onblur='check_yhm("<%=ExistsYHM()%>","jsyhm","pdyhm")'/></div>
<div id="jsyhm" class="resjs">请输入用户名!</div>
<div id="pdwk" class="resjs">用户名不能为空!</div>
<div id="pdyhm" class="resjs">用户名已存在,请重新输入!</div>
<div><input name="Text1" type="text" id="Text1"/></div>
</div>
</li>
</ul>
</div>
</form>
</body>
</html>
C#代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.ComponentModel;
namespace CoolBlog
{
public partial class register : System.Web.UI.Page
{
private readonly coolblog2.BLL.BLLmanager bll = new coolblog2.BLL.BLLmanager();
protected void Page_Load(object sender, EventArgs e)
{
}
public bool ExistsYHM()
{
string yhm = string.Empty;
if (Request.Form.Form["yhmid"]!= null)
{
yhm = Request.Form["yhmid"].ToString();
}
bool YHM = bll.ExistsYHM(yhm);
return YHM;
}
}
}
我的C#代码获取不到<input id="yhmid" name="yhmid" type="text" onfocus='xs_yhm("yhmid","pdwk","jsyhm")' onblur='check_yhm("<%=ExistsYHM()%>","jsyhm","pdyhm")'/>中的值,大家帮我看看问题出在哪里?
就是这个yhm = Request.Form["yhmid"].ToString();中获得的值为空。大家能帮我找出原因吗?