Solved

Creating Pop Windows in ASPNET C#

Posted on 2004-08-14
2
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

687 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