1.11M Members

How to open pop-up window in asp.net web application?

 
0
 
Hi.,
I'm developing a web application,in this application using a gridview data control and show Employee details like Empid, EmpName, designation like that. i need when i click the "Empid" field, to show popup window and list that Employee all details in child window. how to do this? please Anyone can help me..
 
0
 

Try having a look at Windows.Forms.MessageBox. I am not sure if that is something you want.

or you could always use the alert function in JavaScript.

 
0
 

In your gridview you need to add a control such as a link button. When clicked, it should open a small pop-up page. The link button would pass a parameter to this page such as EmpID. Then, on the pop-up page, add a details view control and additional code to query your data source and retrieve the employee's record and display in the details view.

This is just one approach. There are other ways to accomplish the same goal.

 
0
 

Personally, I would stick with using javascript's alert function since it is dead simple to implement, but it is also a simple display, which it seems you are not really interested in, so you may want to try out some jQuery, I know it seems a little daunting at first but it can easily make some of the most beautiful popups I have ever seen, especially colorbox.

To use javascript, in your code behind page you could do something like this

Dim strScript As String = "<a href='javascript:alert("""Employee ID:" & strEmpID & """);'>" & strEmpName & "</a>"

then write that variable into the grid as a link as text however you can.

Using jQuery you could create an iframe that has some text boxes in it and then create a jQuery function that will call the colorbox to display the iframe, maybe make the link like this....

dim strLinkText as string = "<a href='javascript:ShowEmpInfo(" & Chr(34) & "EmpInfo.aspx?empid=" & strEmpID & Chr(34) & ");'><font color='white' backcolor='#738ca0'>" & strEmpName & "</a>"

and then in jQuery/javascript you have a function called ShowEmpInfo...

function ShowEscore(url) {
   // alert(url); //for testing to make sure it is firing

   //iframe ID of EmpInfo
$('#EmpInfo').show();
    $.fn.colorbox({ 'href': '#EmpInfo', 'open': true, 'inline': true, 'width': '800px', 'height': '550px' });
    $().bind('cbox_closed', function () {

        $('#EmpInfo').hide();
    });
}

Now for jQuery you will need to have 2 files included in the .aspx page one for jQuery and one for colorbox, which you will need to grab from the following sites.
http://jquery.com/
http://www.designresourcebox.com/colorbox-lightbox-plugin/

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script> 

Hope this helps...if you need more info I will try to help,
Larry

 
0
 

try to use AJAX.. and use modalpopupExtender. that's the easiest way..

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article