.net 移动web开发 按钮点击后后台事件里无法取到表单的值,始终为空。
如标题,这问题困扰了我很久,希望大哥大姐们积极响应,先谢谢! --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- Login.aspx<%@ Page Language="C#" AutoEventWireup="true" Inherits="W.Web.Login" CodeBehind="Login.aspx.cs" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<mobile:StyleSheet Runat="server" ReferencePath="externalReferencePath">
<mobile:Style Name="txt" Font-Size="Small" />
</mobile:StyleSheet>
<mobile:Form ID="Form1" Runat="server" StyleReference="txt">
<mobile:Image Runat="server" ImageUrl="~/images/logo.gif">
</mobile:Image>
<br />
<mobile:Label ID="Label1" Runat="server">用户名/账号:</mobile:Label>
<mobile:TextBox ID="txtUserName" Runat="server">
</mobile:TextBox>
<mobile:Label ID="Label2" Runat="server">密码:</mobile:Label>
<mobile:TextBox ID="txtUserPwd" Runat="server" Password="True">
</mobile:TextBox>
<mobile:Command ID="cmdLogin" Runat="server" OnClick="cmdLogin_Click">登录</mobile:Command>
<mobile:Label ID="lbMsg" Runat="server">
</mobile:Label>
<mobile:Label ID="lbTime" Runat="server">
</mobile:Label>
</mobile:Form>
</body>
</html>
Login.aspx.cs
using System;
namespace W.Web
{
public partial class Login : System.Web.UI.MobileControls.MobilePage
{
protected string BackUrl = "~/Default.aspx";
protected Sr_Members.Ws_MembersSoapClient user = new W.Web.Sr_Members.Ws_MembersSoapClient();
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["backurl"] != null)
{
BackUrl = Request.Params["backurl"];
int i = BackUrl.IndexOf('?');
if (i != -1)
{
BackUrl = BackUrl.Substring(0, i);
}
}
if (Session["UserName"] != null)
{
Response.Redirect(BackUrl);
}
lbTime.Text = DateTime.Now.ToString("[MM-dd HH:mm]");
}
protected void cmdLogin_Click(object sender, EventArgs e)
{
string username = txtUserName.Text;
string userpwd = txtUserPwd.Text;
lbMsg.Text = "123:" + username;
//if (string.IsNullOrEmpty(username))
//{
// lbMsg.Text = "请输入用户名!";
// return;
//}
//if (string.IsNullOrEmpty(userpwd))
//{
// lbMsg.Text = "请输入密码";
// return;
//}
//if (user.Mem_Login(username, W.Common.MD5.Encrypt(userpwd)))
//{
// Session["UserName"] = username;
// Response.Redirect(BackUrl);
//}
//else
//{
// lbMsg.Text = "用户名或密码错误!";
//}
}
}
} --------------------编程问答-------------------- 我用windows mobile 6.1系统机来测试的。
补充:.NET技术 , ASP.NET