我想在可折叠面板扩展器上显示登录表单以登录用户。请帮助我解决这个 Ajax 问题。
问问题
508 次
3 回答
2
我得到了答案,但是。它仅适用于 IE。它不适用于 Firefox。您的评论很荣幸。
//添加第一个脚本管理器
然后.....
<div class="secpanel">
<table id="login">
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>User name:</td>
<td>
<asp:TextBox ID="usrtxt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<asp:TextBox ID="passtxt" TextMode="Password" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="loginbtn" runat="server" Text="Login" ValidationGroup="g1"
onclick="loginbtn_Click"/></td>
</tr>
<tr>
<td colspan="2">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please enter user name" ControlToValidate="usrtxt"
ForeColor="Red" ValidationGroup="g1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="Please enter password" ControlToValidate="passtxt"
ForeColor="Red" ValidationGroup="g1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="err" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
</div>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" TargetControlID="secpanel" CollapseControlID="fstpanel" ExpandDirection="Vertical" TextLabelID="lbl" CollapsedText="Click to login" ExpandedText="Hide" CollapsedSize="0" ExpandedSize="200" ExpandControlID="fstpanel" Collapsed="true" ScrollContents="false" runat="server">
</asp:CollapsiblePanelExtender>
//提交按钮的代码
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["hw"].ConnectionString.ToString();
con.Open();
SqlCommand cmd = new SqlCommand("select * from Login where Admin_name=@", con);
//cmd.Parameters.Add("@user", usrtxt.Text);
//cmd.Parameters.AddWithValue("@user", usrtxt.Text);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if((usrtxt.Text==dr.GetString(1)) && (passtxt.Text==dr.GetString(2)))
{
Session["admin"]=dr.GetString(1);
Response.Redirect("Admin.aspx");
}
else
{
err.Text="You are not autorized";
}
cmd.Dispose();
}
con.Close();
于 2012-10-26T10:03:02.680 回答
0
可能是浏览器的问题。尝试使用其他浏览器。
于 2012-10-26T09:57:06.990 回答
0
我认为您的代码不完整。如果你想实现可折叠面板......你必须使用两个面板,一个用于标题,另一个用于内容。最后在 Collapsible Panel Extender 中设置如下选项。
<Ajax:CollapsiblePanelExtender ID="CollapsiblePanelext1" runat="server" CollapseControlID="pnl1Head" Collapsed="true" ExpandControlID="pnl1Head" TextLabelID="lblMessage" CollapsedText="Show" ExpandedText="Hide" ImageControlID="imgArrows" ExpandDirection="Vertical" TargetControlID="pnl2Content" ScrollContents="True" ExpandedImage="../images/collapse_blue.jpg" CollapsedImage="../images/expand_blue.jpg"> </Ajax:CollapsiblePanelExtender>
于 2014-01-17T11:40:09.353 回答