弹出页面,当点击一个链接按钮时
<td colspan ="2" style="width: 64px">
<div style="float:left; padding-left:9px;">
<asp:LinkButton ID="lnkremoveloc" runat="server"
OnClick="lnkremoveloc_Click" CssClass="linkclass"
style="cursor:pointer" Font-Underline="True"
Font-Bold="true" Font-Size="12px">
Remove Location
</asp:LinkButton>
</div>
</td>
这是从哪里点击时弹出的链接按钮。 弹出页面如下所示。但是当我点击这个链接时,同一个页面会被刷新,我松开保存并取消按钮,而不是打开一个弹出窗口。有人可以帮我吗。我不知道我在做错什么。非常感谢...弹出页面,当点击一个链接按钮时
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DisableLocation.aspx.cs" Inherits="DisableLocation" %>
<!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" >--%>
<script language ="javascript" type="text/javascript" >
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no,
status=no, menubar=no,scrollbars=no, resizable=no, copyhistory=no, width='+w+',
height='+h+', top='+top+', left='+left);
}
</script language ="javascript" type="text/javascript">
<html>
<head runat="server">
<title>Disable Location | DealTown.com</title>
</head>
<body>
<form id="form1" runat="server">
<div style="display: block; background: url(images/reusable_blue_bg.jpg) repeat-x 0 -15px;border-left: #88b9c7 1px solid; border-bottom:#88b9c7 1px solid; border-top:#88b9c7 1px solid; border-right: #88b9c7 1px solid; padding: 0px 2px; height: 236px; min-height: 236px; height: auto; margin-left: auto; margin-right: auto;">
<table align="center" style="width: 554px; border-top-style: none; border-right-style: none;
border-left-style: none; border-bottom-style: none" id="TABLE1">
<tr >
<td align="center" colspan="5" style="font-weight:normal;font-size:18px;margin: 0px;font-family: Arial;color: #1e7c9b;" >Disable Location</td>
</tr>
<asp:GridView ID="diableloc" runat="server" AutoGenerateColumns="False"
DataKeyNames="LocationName" DataSourceID="getGridMerchantLocationData"
AllowPaging="True" EnableViewState="False">
<Columns>
<asp:BoundField DataField="chkbox" HeaderText="Select"
SortExpression="Selection" />
<asp:BoundField DataField="locname" HeaderText="Location Name"
ReadOnly="True" SortExpression="Locnames" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ProductsDataSource" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetLocations" TypeName="string">
</asp:ObjectDataSource>
</table>
<tr>
<td style="width: 44px; height: 63px">
</td>
<td style="width: 127px; height: 63px">
</td>
<td align="left" colspan="2" style="height: 63px; width: 196px;">
<asp:ImageButton ID="btnDisable" runat="server" ImageUrl="~/images/save.gif" OnClick="btnDisable_Click"
ValidationGroup="group1" />
<asp:ImageButton ID="btnCancel" runat="server" ImageUrl="~/images/cancel.gif" OnClick="btnCancel_Click" /></td>
<td colspan="1" style="width: 92px; height: 63px">
</td>
</tr>
</div>
</form>
</body>
</html>
听起来像页面回传。你试过AutoPostBack="false"
?不知道你需要一个LinkButton在这里。你可以用onclick
的锚标签来调用弹出窗口吗?
您点击LinkButton时是否需要在服务器端执行代码?如果您需要两者都可以使用OnClientClick属性来兼得。 它已经有一段时间了,但我认为你可以这样做,如果onclientclick中客户端代码返回的值返回false,服务器代码将不会执行。
我看不到你当前的LinkButton如何显示弹出窗口。
而不是OnClick
使用OnClientClick="lnkremoveloc_Click"
其中lnkremoveloc_Click是打开弹出窗口的JavaScript函数(类似PopupCenter的东西)。
设置onclientclick
而不是onclick
。而渲染(页面加载)本身将onclientclick
设置为"PopupCenter('url','title',....);return false;"
可以在加载时设置url,title,width等。最后一部分“返回false”将取消点击的效果。因此它可以防止回帖。
注意:如果你想在服务器端要处理的东西,它最好不要设置onclientclick
和使用 Response.write("<script>PopupCenter('url','title',....);</script>");
我希望帮助。
这是我的第一篇文章:)