ASP.NET - Pop up window after image button click in asp.net

Asked By Aksara L.P on 22-Jul-11 05:11 AM
Pop up window after image button click  in asp.net
Reena Jain replied to Aksara L.P on 22-Jul-11 05:12 AM
hi,

try this and let me know


<asp:Imagebutton ID="lnk" NavigateUrl="~/YourPage.aspx" runat="server" Text="click" ></asp:Imagebutton>

or in your C# client side code (event):
RegisterStartupScript("SomeNameForThisScript", "window.open('YourPage.aspx');");

When you page is served up, the startup script will fire and open a new window.

Hope this will help you
Kalit Sikka replied to Aksara L.P on 22-Jul-11 05:17 AM

<%@ Page Language="C#" %>
<%@ Import namespace="System.Text" %>
<script runat="server">

    void Page_load(object sender, EventArgs e)
    {
     ImageLink .Attributes.Add( "onclick", "popWin()" );
   }

</script>
<html>
<head>

  <script>
   function popWin(){
      window.open('http://msdn.microsoft.com', '', '');");
   }
   </script>
  </head>
<body>
    <form runat="server">
      <asp:ImageLink id="Image1"  runat="server" Text="Go!"></asp:ImageLink >
    </form>
</body>
</html>

Riley K replied to Aksara L.P on 22-Jul-11 05:38 AM
You can do that using JavaScript


<asp:ImageButton ID="CallHistory_IB" runat="server" ImageUrl="~/Images/Find.ico"  OnClick=OpenNewWindow_OnClick >

In the button click write the javascript code to open new window

Protected Sub OpenNewWindow_OnClick(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
 
Response.Write("<script language="javascript">window.open('newpage.aspx?id='" & read_value_from_grid_cell & ")</script>")
 
End Sub

Try this and let me know

Jitendra Faye replied to Aksara L.P on 22-Jul-11 05:38 AM

If you want to show popup then use jquery popup.

after adding jqueryui plugin you can use it.

like this-

<script>

function funShow() {

$('#dialog).dialog({ resizable: false, height: 140, modal: true });

}
</script>

<div id="dialog" title="Basic dialog">hi
</div>


<asp:ImageButton runat="server" Text="Button" onClientClick="return funShow()" />

FOR EXAMPLE FOLLOW THIS

-http://jqueryui.com/demos/dialog/


dipa ahuja replied to Aksara L.P on 22-Jul-11 07:23 AM
Use the ajaxModalPopup Extender and provide the TargetControlID as the id of ImageButton
<cc1:ModalPopupExtender TargetControlID="impPop" 
  BackgroundCssClass="modalBackground"
  PopupControlID="Panel1" OkControlID="btnok" 
  CancelControlID="btnCancel" PopupDragHandleControlID="btnok"
  ID="ModalPopupExtender3" runat="server" />
<asp:ImageButton ID="impPop" runat="server" />
<asp:Panel ID="Panel2" runat="server" Height="80" CssClass="ModalWindow">
  <%--Take textboxes here--%>
  <asp:Label ID="Label1" runat="server" Text="Records Updata Popup"/>
  <asp:LinkButton ID="LinkButton5" runat="server" Text="X" /><br />
  <asp:Button ID="btnok"  runat="server" Text="Submit" />
  <asp:Button ID="btnCancel"  runat="server" Text="Cancel" />
    
</asp:Panel>