2010-08-04 118 views
0
<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> 

回答

0

聽起來像頁面回傳。你試過AutoPostBack="false"?不知道你需要一個LinkBut​​ton在這裏。你可以用onclick的錨標籤來調用彈出窗口嗎?

您點擊LinkBut​​ton時是否需要在服務器端執行代碼?如果您需要兩者都可以使用OnClientClick屬性來兼得。 它已經有一段時間了,但我認爲你可以這樣做,如果onclientclick中客戶端代碼返回的值返回false,服務器代碼將不會執行。

我看不到你當前的LinkBut​​ton如何顯示彈出窗口。

0

而不是OnClick使用OnClientClick="lnkremoveloc_Click"其中lnkremoveloc_Click是打開彈出窗口的JavaScript函數(類似PopupCenter的東西)。

0

設置onclientclick而不是onclick。而渲染(頁面加載)本身將onclientclick設置爲"PopupCenter('url','title',....);return false;"

可以在加載時設置url,title,width等。最後一部分「返回false」將取消點擊的效果。因此它可以防止回帖。

注意:如果你想在服務器端要處理的東西,它最好不要設置onclientclick和使用 Response.write("<script>PopupCenter('url','title',....);</script>");

我希望幫助。

這是我的第一篇文章:)

相關問題