[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Creating Pop Windows in ASPNET C#

Posted on 2004-08-14
2
Medium Priority
?
344 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 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
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).
Suggested Courses

650 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