弹出网页表单没有按钮和超链接
Posted
技术标签:
【中文标题】弹出网页表单没有按钮和超链接【英文标题】:Pop up for web form doesn't with button and hyberlink 【发布时间】:2018-12-28 08:26:25 【问题描述】:当您单击gridview中的任何行时,如何创建弹出表单。它将弹出一个显示详细信息的表单。我不想要带有任何按钮或超链接的 gridview。
【问题讨论】:
你能告诉我们你的代码吗?您在谈论哪种弹出窗口,到目前为止您尝试过什么? 讨厌那些超链接。 使用引导模式弹出窗口。 jsfiddle.net/KyleMit/0fscmf3L 看看jquery-ui dialog。 【参考方案1】:希望对您有所帮助!
将 AjaxControlToolkit.dll 添加到您的 bin 文件夹并像这样设计您的 aspx 页面
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.modalBackground
background-color: Gray;
filter: alpha(opacity=80);
opacity: 0.8;
z-index: 10000;
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div>
<asp:GridView runat="server" ID="gvdetails" DataKeyNames="UserId" AutoGenerateColumns="false">
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="imgbtn" ImageUrl="~/Edit.jpg" runat="server" Width="25" Height="25" onclick="imgbtn_Click" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UserName" HeaderText="UserName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Designation" HeaderText="Designation" />
</Columns>
</asp:GridView>
<asp:Label ID="lblresult" runat="server"/>
<asp:Button ID="btnShowPopup" runat="server" style="display:none" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlpopup"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="269px" Width="400px" Style="display: none">
<table style="border: Solid 3px #D55500; width: 100%; height: 100%" cellpadding="0" cellspacing="0">
<tr style="background-color: #D55500">
<td colspan="2" style="height: 10%; color: White; font-weight: bold; font-size: larger" align="center">User Details</td>
</tr>
<tr>
<td align="right" style="width: 45%">UserId:
</td>
<td>
<asp:Label ID="lblID" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="right">UserName:
</td>
<td>
<asp:Label ID="lblusername" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="right">FirstName:
</td>
<td>
<asp:TextBox ID="txtfname" runat="server" />
</td>
</tr>
<tr>
<td align="right">LastName:
</td>
<td>
<asp:TextBox ID="txtlname" runat="server" />
</td>
</tr>
<tr>
<td align="right">City:
</td>
<td>
<asp:TextBox ID="txtCity" runat="server" />
</td>
</tr>
<tr>
<td align="right">Designation:
</td>
<td>
<asp:TextBox ID="txtDesg" runat="server" />
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" OnClick="btnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
BindGridData()
End If
End Sub
Protected Sub BindGridData()
con.Open()
Dim cmd As New SqlCommand("Select * from Employee_Details", con)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
da.Fill(dt)
gvdetails.DataSource = dt
gvdetails.DataBind()
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs)
con.Open()
Dim cmd As New SqlCommand("update Employee_Details set FirstName=@FirstName,LastName=@LastName, City=@City,Designation=@Designation where UserId=@UserId", con)
cmd.Parameters.AddWithValue("@FirstName", txtfname.Text)
cmd.Parameters.AddWithValue("@LastName", txtlname.Text)
cmd.Parameters.AddWithValue("@City", txtCity.Text)
cmd.Parameters.AddWithValue("@Designation", txtDesg.Text)
cmd.Parameters.AddWithValue("@UserId", Convert.ToInt32(lblID.Text))
cmd.ExecuteNonQuery()
con.Close()
lblresult.Text = lblusername.Text + " Details Updated Successfully"
lblresult.ForeColor = Color.Green
BindGridData()
End Sub
Protected Sub imgbtn_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
Dim btndetails As ImageButton = TryCast(sender, ImageButton)
Dim gvrow As GridViewRow = DirectCast(btndetails.NamingContainer, GridViewRow)
lblID.Text = gvdetails.DataKeys(gvrow.RowIndex).Value.ToString()
lblusername.Text = gvrow.Cells(1).Text
txtfname.Text = gvrow.Cells(2).Text
txtlname.Text = gvrow.Cells(3).Text
txtCity.Text = gvrow.Cells(4).Text
txtDesg.Text = gvrow.Cells(5).Text
Me.ModalPopupExtender1.Show()
End Sub
【讨论】:
以上是关于弹出网页表单没有按钮和超链接的主要内容,如果未能解决你的问题,请参考以下文章
关于script中alter弹出警告对话框之后,其确定按钮怎么链接到其他页面?
IE浏览器浏览网页时,所有要弹出新窗口的链接点击了都没有用了是怎么回事?