Showing posts with label PopUp Window. Show all posts
Showing posts with label PopUp Window. Show all posts

Open Popup Without User Action or Webform On Click Using JavaScript in Asp.Net

Open Popup Without User Action or Webform ClicK

If Click on Webform form Without user action popup open new tab or same page using in Asp.Net C#.

                                 DEMO



                             Download

                        HTML Coding


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript">


        // Open popup in Same Page without user action

        document.addEventListener('click',function()
        {
            window.open('http://www.dotnetdrizzles.blogspot.in','','width=250 height=250');

        })
     
        // Open  New Tab without user action

        document.addEventListener('click',function()
        {
            window.open('http://www.dotnetdrizzles.blogspot.in', 'width=250 height=250');
        })

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>

</html>


Add - New Form - Add Javascript AddEventListener Click Function





Display Original Image Size in New Window When Clicking on the Image Using JavaScript Asp.Net

Display Original Image Size in new window when clicking on the Image

Open Popup Window When Image Click Show Same Window or New Blank Window or Default Size Window Show Image Using Javascript Asp.Net C#.

                Download Coding

                       Download

                       DEMO
                               

                      
                            HTML CODING


<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title></title>
<script type="text/javascript" lang="javascript">
// Open window 
    function DisplayInWidnow() {
        var popupimage = document.getElementById('<%= Image1.ClientID %>').src;
        html = "<HTML><HEAD><TITLE>Photo</TITLE>"
        + "</HEAD><BODY LEFTMARGIN=0 "
        + "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>"
        + "<IMG src='"
        + popupimage
        + "' BORDER=0 NAME=image "
        + "onload='window.resizeTo(document.image.width,document.image.height)'>"
        + "</CENTER>"
        + "</BODY></HTML>";
        popup = window.open('', 'image', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
        popup.document.open();
        popup.document.write(html);
        popup.document.focus();
        popup.document.close();
    }

// New Tab OPen
    function DisplayInWidnow1() {
        var popupimage = document.getElementById('<%= Image2.ClientID %>').src;
        html = "<HTML><HEAD><TITLE>Photo</TITLE>"
        + "</HEAD><BODY LEFTMARGIN=0 "
        + "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>"
        + "<IMG src='"
        + popupimage
        + "' BORDER=0 NAME=image "
        + "onload='window.resizeTo(document.image.width,document.image.height)'>"
        + "</CENTER>"
        + "</BODY></HTML>";
        popup = window.open('');
        popup.document.open();
        popup.document.write(html);
        popup.document.focus();
        popup.document.close();
    }


</script></head>

<body>
<div>   
   
<asp:Image ID="Image1" width="100px" height ="100px"  runat="server" ImageUrl = "~/image/Koala.jpg" onclick="DisplayInWidnow();"/>
    &nbsp;
    <asp:Image ID="Image2"  width="100px" height ="100px"  runat="server" ImageUrl = "~/image/Penguins.jpg" onclick="DisplayInWidnow1();" />
</div>

</body>
</html>


First - Add - New - Web Form - Select Image Control From ToolBox - F4 Property - Assign - ImageURL - Image 





Next - Add JavaScript File form Image1 & Image2 






Show - Image Source Code For onclick Function Calling











Open PopUp Window on the Button Click Event Using in Asp.Net C#

Open PopUp Window

Click The Button Open The popup Window  Display Particular Size  and New Tab and Default Size Using  in Asp.Net C#.
   
                        Download Coding
                                            Download


                                  DEMO



                    

                        HTML CODING


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="Button1" runat="server"  Text="Open Window Url" OnClick="Button1_Click" />
    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Open Without Size" />
    <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Open New Browser" />
</div> 

</form>
</body>

</html>


C# CODING


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

 // Small Size Window open

        TextBox1.Text = HttpContext.Current.Request.Url.AbsoluteUri;

        string popup = "window.open('" + TextBox1.Text + "','popup_window','left=200,top=100,width=100,height=100');";

        ClientScript.RegisterStartupScript(this.GetType(), "PopUp1", popup, true);

    }

    protected void Button2_Click(object sender, EventArgs e)
    {

 // Default Size Window open

        TextBox1.Text = HttpContext.Current.Request.Url.AbsoluteUri;

        string popup = "window.open('" + TextBox1.Text + "','','popup_window');";

        ClientScript.RegisterStartupScript(this.GetType(), "PopUp2", popup, true);

    }
    protected void Button3_Click(object sender, EventArgs e)
    {

 // New Tab Window open

        TextBox1.Text = HttpContext.Current.Request.Url.AbsoluteUri;

        string popup = "window.open('" + TextBox1.Text + "');";

        ClientScript.RegisterStartupScript(this.GetType(), "PopUp3", popup, true);

    }

}


First - Add - New WebForm - Select Textbox & Button Control From Toolbox 





Next - Double Click Button - Url Get Directly Textbox - 3 Type Open Window - Fixed Size,Default Size,New Tab