Solved

Creating Pop Windows in ASPNET C#

Posted on 2004-08-14
2
334 Views
Last Modified: 2006-11-17
Dear Expert,
  I am fairly new to .net develop using C# and ASPNET. I have an application were I need to create pop-up window for quick help referencing and hints. I wanted to use either a hyperlink or a link webform control. I am not sure how to go about using either of these control create the desired a pop-up window functionality. I am  open to suggestions.

Thanks for the help


-K
0
Comment
Question by:Khopkins32
2 Comments
 
LVL 18

Accepted Solution

by:
tusharashah earned 125 total points
ID: 11802706
For the Web server controls, you cannot simply use the HTML syntax to add client-side event handling. The reason is that for some controls, ASP.NET already uses client-side event handling to perform automatic postback operations. The preferred way to add client-side evnet handling code for Web server controls is via the use of the Attributes property of the Web server controls. For example, the following code fragment attaches the someClientCode() client-side method to the OnMouseOver attribute of the btnSubmmit button (POP-UP)
--------------------------------------------------------------------------------
Insert a <script> element under the <head> element to add the client-side function as shown here:

<head>
...
      <script language='javascript'>
            function btnSubmit_ClientClick()
            {
             alert("YOU CLICKED btn ") ;
            }
      </script>

</head>

- Now add an onClick attribute to the btnSubmit control's attribute collection to execute the client-side function added up above. Add following code in Page_Load of your code-behind

private void Page_Load(object sender, System.EventArgs e)
{
      btnSubmit.Attributes.Add("onclick", "btunSubmit_ClientClick();");
}


}

--------------------------------------------------------------------------------

You can also setup other javascript function like this
-tushar
0
 
LVL 3

Expert Comment

by:bigjim2000
ID: 11807647
Here's what I'd do:

First, put the following code somewhere in the <head></head> tags:
<script language="javascript">
function popUp(URL,xsize,ysize)
{
      day = new Date();
      id = day.getTime();
      eval("page" + id + " = window.open(URL, '" + id + "', 'width=' + xsize + ',height=' + ysize + ',left = 835.5,top = 475.5');");
}
</script>

Lets say you have some link on your page.  Normally, the code would look as follows:
<a href="somepage.html">My other page</a>

Now lets say you want this page to pop-up when you load your server control (which is what I'm assuming you want to do).
Your link would now look like this:
<a href="javascript:popUp('somepage.html', '100', '100');">My other POPUP page</a>

Note, the 100 and 100 are the x and y dimensions of the new page.  This is handy if you want your pages to appear a certain size.

Hope this helped.

-Eric
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP extract HTML using DOMXpath from nested tables 8 56
File download script VBSCRIPT fail on download PPT files 2 51
Help with query 3 23
Scroll 5 news at a time. 4 25
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question