标题:[求助]imagebutton问题请大家帮忙
只看楼主
andrew77
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-1-11
 问题点数:0 回复次数:1 
[求助]imagebutton问题请大家帮忙

我写的登录的用户组件在输入用户名和密码后点击登陆的imagebutton按钮没有反应.在局域网下没有问题,上传到网站空间后就出现上面的情况.将imagebutton换成button也有同样现象,但换成linkbutton就可以.请大家帮帮我.谢谢了.代码如下:
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="userlogin.ascx.cs" Inherits="moliksys.usermodules.userlogin" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<TABLE id="Table2" cellSpacing="0" cellPadding="0" width="90%" border="0">
<TR>
<td colSpan="3"><FONT face="宋体"> </FONT>
</td>
</TR>
<TR>
<TD style="WIDTH: 16px" align="right"><asp:image id="Image1" runat="server" ImageUrl="../images/obj_frame_top1.gif"></asp:image><asp:image id="Image5" runat="server" ImageUrl="../images/obj_frame_top2.gif"></asp:image></TD>
<TD background="images/obj_frame_top2.gif"><asp:image id="Image4" runat="server" ImageUrl="../images/obj_frame_top.gif"></asp:image></TD>
<TD width="2"><FONT face="宋体"><asp:image id="Image2" runat="server" ImageUrl="../images/obj_frame_top3.gif"></asp:image></FONT></TD>
</TR>
<TR>
<TD style="WIDTH: 16px; HEIGHT: 19px" align="right" bgColor="#6699ff"><asp:image id="Image3" runat="server" ImageUrl="../images/p_point02.gif"></asp:image><asp:image id="Image9" runat="server" ImageUrl="../images/p_point02.gif"></asp:image></TD>
<TD style="HEIGHT: 19px" bgColor="#6699ff">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="100%" bgColor="#6699ff" border="0"
runat="server">
<TR>
<td colSpan="2"><FONT face="宋体">
<P align="center"> </P>
</FONT>
</td>
</TR>
<TR>
<td>
<asp:label id="lb_name" runat="server" ForeColor="White">用户名:</asp:label></td>
<td><asp:textbox id="tb_name" runat="server" Width="100px"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" Display="None" ControlToValidate="tb_name"
ErrorMessage="请输入用户名!"></asp:requiredfieldvalidator><asp:label id="lb_nameshow" runat="server" ForeColor="White" Visible="False"></asp:label></td>
</TR>
<TR>
<td>
<asp:label id="lb_pwd" runat="server" ForeColor="White">密码:</asp:label>
<asp:LinkButton id="LinkButton2" runat="server">L</asp:LinkButton></td>
<td><FONT face="宋体"><asp:textbox id="tb_pwd" runat="server" Width="100px" TextMode="Password"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" Display="None" ControlToValidate="tb_pwd"
ErrorMessage="请输入密码!"></asp:requiredfieldvalidator><asp:label id="lb_othershow" runat="server" ForeColor="White" Visible="False"></asp:label></FONT></td>
</TR>
<TR>
<td colSpan="2"><FONT face="宋体">
<P align="center"> </P>
</FONT>
</td>
</TR>
</TABLE>
<asp:validationsummary id="ValidationSummary1" runat="server" ShowSummary="False" ShowMessageBox="True"></asp:validationsummary></TD>
<TD style="HEIGHT: 19px" bgColor="#6699f"></TD>
</TR>
<TR>
<TD style="WIDTH: 16px" bgColor="#6699ff"></TD>
<TD bgColor="#6699ff"><FONT face="宋体">
<P align="center"><asp:imagebutton id="imgbtn_login" runat="server" ImageUrl="../images/bt2_go.gif"></asp:imagebutton>
<asp:hyperlink id="hl_login" runat="server" ImageUrl="../images/bt2_login.gif" Target="_blank"
NavigateUrl="~/usermanage.aspx"></asp:hyperlink><BR>
<asp:hyperlink id="hl_edituser" runat="server" ForeColor="White" Visible="False" Font-Bold="True">[修改用户信息]</asp:hyperlink><br>
<asp:hyperlink id="HyperLink1" runat="server" ForeColor="White" Visible="False" NavigateUrl="~/loginoff.aspx"
Font-Bold="True">[退出登录]</asp:hyperlink><br>
<asp:linkbutton id="LinkButton1" runat="server" ForeColor="White" Font-Bold="True" CausesValidation="False">[找回密码]</asp:linkbutton>
</P>
</FONT>
</TD>
<TD bgColor="#6699ff"></TD>
</TR>
<TR>
<TD style="WIDTH: 16px" align="right"><asp:image id="Image7" runat="server" ImageUrl="../images/obj_frame_bottom1.gif"></asp:image><asp:image id="Image8" runat="server" ImageUrl="../images/obj_frame_bottom2.gif"></asp:image></TD>
<TD background="images/obj_frame_bottom2.gif"><FONT face="宋体"></FONT></TD>
<TD><asp:image id="Image6" runat="server" ImageUrl="../images/obj_frame_bottom3.gif"></asp:image></TD>
</TR>
<TR>
<TD style="WIDTH: 16px" align="right"> </TD>
<TD> </TD>
<TD> </TD>
</TR>
</TABLE>
后台代码:
namespace moliksys.usermodules
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

/// <summary>
/// userlogin 的摘要说明。
/// </summary>
public class userlogin : System.Web.UI.UserControl
{
protected System.Web.UI.HtmlControls.HtmlTable Table1;
protected System.Web.UI.HtmlControls.HtmlTableCell TD2;
protected System.Web.UI.WebControls.TextBox tb_name;
protected System.Web.UI.WebControls.TextBox tb_pwd;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
private linkdatabase link=new linkdatabase();
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Image Image2;
protected System.Web.UI.WebControls.Image Image3;
protected System.Web.UI.WebControls.Image Image4;
protected System.Web.UI.WebControls.Image Image5;
protected System.Web.UI.WebControls.Image Image6;
protected System.Web.UI.WebControls.Image Image7;
protected System.Web.UI.WebControls.Image Image8;
protected System.Web.UI.WebControls.Label lb_name;
protected System.Web.UI.WebControls.Label lb_nameshow;
protected System.Web.UI.WebControls.Label lb_othershow;
protected System.Web.UI.WebControls.Label lb_pwd;
protected System.Web.UI.WebControls.HyperLink hl_edituser;
protected System.Web.UI.WebControls.HyperLink hl_login;
protected System.Web.UI.WebControls.Image Image9;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.ImageButton imgbtn_login;
private DataSet ds=new DataSet();

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面


Response.Write("<script>alert('"+Session["loginflag"].ToString()+"')</script>");
if((bool)Session["loginflag"]==true)
{
this.tb_name.Visible=false;
this.tb_pwd.Visible=false;
this.imgbtn_login.Visible=false;
this.hl_login.Visible=false;
this.lb_nameshow.Visible=true;
this.lb_nameshow.Text=Session["username"].ToString();
this.lb_pwd.Text="用户角色:";
this.lb_othershow.Visible=true;
this.lb_othershow.Text=Session["rolename"].ToString();
this.hl_edituser.Visible=true;
this.hl_edituser.NavigateUrl="usermanage.aspx?userid="+Session["userid"].ToString();
this.HyperLink1.Visible=true;
this.LinkButton1.Visible=false;
}

}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void imgbtn_login_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
string checkstr="SELECT 角色表.角色编号, 角色表.角色名称, 角色表.角色权限, 用户表.用户编号, 用户表.用户名称, 用户表.密码, 用户表.电子邮箱, 用户表.所属角色编号, 用户表.真实姓名, 用户表.地址, 用户表.电话, 用户表.移动电话, 用户表.密码问题, 用户表.问题答案, 用户表.用户建立时间, 用户表.上一次登录时间, 用户表.更新时间, 用户表.访问次数, 用户表.头像编号, 用户表.用户权限, 用户表.性别 FROM 角色表 INNER JOIN 用户表 ON 角色表.角色编号 = 用户表.所属角色编号 where 用户名称='"+clearstring.inputtext(this.tb_name.Text.Trim(),this.tb_name.Text.Length)+"' and 密码='"+clearstring.inputtext(this.tb_pwd.Text.Trim(),this.tb_pwd.Text.Length)+"'";
string checktb="临时表";

ds=this.link.selectdatabase(checkstr,checktb);

if (ds.Tables[0].Rows.Count>0)
{

Session["username"]=ds.Tables["临时表"].Rows[0]["用户名称"].ToString();
Session["userid"]=ds.Tables["临时表"].Rows[0]["用户编号"].ToString();
Session["realname"]=ds.Tables["临时表"].Rows[0]["真实姓名"].ToString();
Session["permiss"]=ds.Tables["临时表"].Rows[0]["用户权限"].ToString();
Session["rolename"]=ds.Tables["临时表"].Rows[0]["角色名称"].ToString();
Session["roleid"]=ds.Tables["临时表"].Rows[0]["角色编号"].ToString();
Session["loginflag"]=true;
Response.Redirect("index.aspx");
}
else
{
this.tb_name.Text="";
this.tb_pwd.Text="";
Response.Write("<script>alert('你的用户名或密码有误,请重新输入!')</script>");
}
}

private void LinkButton1_Click(object sender, System.EventArgs e)
{
Response.Write("<script>window.open('forgotpwd.aspx','newwin','width=500,height=300');</script>");
Response.Write("<script>window.focus();</script>");
}

private void LinkButton2_Click(object sender, System.EventArgs e)
{
string checkstr="SELECT 角色表.角色编号, 角色表.角色名称, 角色表.角色权限, 用户表.用户编号, 用户表.用户名称, 用户表.密码, 用户表.电子邮箱, 用户表.所属角色编号, 用户表.真实姓名, 用户表.地址, 用户表.电话, 用户表.移动电话, 用户表.密码问题, 用户表.问题答案, 用户表.用户建立时间, 用户表.上一次登录时间, 用户表.更新时间, 用户表.访问次数, 用户表.头像编号, 用户表.用户权限, 用户表.性别 FROM 角色表 INNER JOIN 用户表 ON 角色表.角色编号 = 用户表.所属角色编号 where 用户名称='"+clearstring.inputtext(this.tb_name.Text.Trim(),this.tb_name.Text.Length)+"' and 密码='"+clearstring.inputtext(this.tb_pwd.Text.Trim(),this.tb_pwd.Text.Length)+"'";
string checktb="临时表";

ds=this.link.selectdatabase(checkstr,checktb);

if (ds.Tables[0].Rows.Count>0)
{

Session["username"]=ds.Tables["临时表"].Rows[0]["用户名称"].ToString();
Session["userid"]=ds.Tables["临时表"].Rows[0]["用户编号"].ToString();
Session["realname"]=ds.Tables["临时表"].Rows[0]["真实姓名"].ToString();
Session["permiss"]=ds.Tables["临时表"].Rows[0]["用户权限"].ToString();
Session["rolename"]=ds.Tables["临时表"].Rows[0]["角色名称"].ToString();
Session["roleid"]=ds.Tables["临时表"].Rows[0]["角色编号"].ToString();
Session["loginflag"]=true;
Response.Redirect("index.aspx");
}
else
{
this.tb_name.Text="";
this.tb_pwd.Text="";
Response.Write("<script>alert('你的用户名或密码有误,请重新输入!')</script>");
}
}


}
}

搜索更多相关主题的帖子: imagebutton 
2007-01-11 12:15
zhou
Rank: 1
等 级:禁止发言
帖 子:429
专家分:0
注 册:2006-6-16
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2008-03-30 17:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-115401-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.035966 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved