Open small window on listbox SelectedIndexChanged

What I would liek to do is upon picking an item from a listbox is for a small window to open up telling information about what was picked.  For the information it can be done within the page3 behind by passing a caouple variables to it or I can pass all the variables to it, whatever way is easier for coding.  But the big question is first.  How can I make a window open from a listbox
SelectedIndexChanged  that is smaller than original page and can be clodes when they are done viewing the information.  I would prefer all vb.net 1.1 ways but will look at javascript if its easy to pass either a couple variables or maybe lots of variables to page.
kdeutschAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin McDanielSr. Developer/ConsultantCommented:
The only browser-indepent and browser-safe way to open a physically separate window and control the window's size is to use JavaScript. Unfortunately, these are subject to the end-user's preference for pop-up windows.

The JavaScript code is very easy... it's simply

function_name (optional_variables)
{
    window.open("url_to_open_relative_or_absolute", "new_window_name"[, "window_features"]);
    return false; // this can be in the calling function, rather than here
}

If you want to use them, here's a list of window attributes you can set... I assume you'll want to use at least the window width and height, and probably the positioning.

status:  The status bar at the bottom of the window.
toolbar:  The standard browser toolbar, with buttons such as Back and Forward.
location:  The Location entry field where you enter the URL.
menubar:  The menu bar of the window
directories:  The standard browser directory buttons, such as What's New and What's Cool
resizable:  Allow/Disallow the user to resize the window.
scrollbars:  Enable the scrollbars if the document is bigger than the window
height:  Specifies the height of the window in pixels. (example: height='350')
width:  Specifies the width of the window in pixels.

* list taken from http://www.javascript-coder.com/window-popup/javascript-window-open.phtml . There's a good tutorial there also.

You can also open DHTML "windows" that won't be blocked... You can do these by hand or use some other 3rd party tool that generates the code for you at design time.
0
kdeutschAuthor Commented:
azarc3:
Now this is for calling a standard asp.net page with javascript.  i need to put information on the page and send it two variables via the hyperlink if this is the case.  I need it to run 2 sql select scripts and show results on the page.
0
kdeutschAuthor Commented:
How would I call this function from my code behind page as part of my listbox selectedIdexchanged event.
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Kelvin McDanielSr. Developer/ConsultantCommented:
No problem; you can pass query-string variables just like with any link.  :)

Once you get spawn the new window it behaves just like any other page request.
<script type="text/javascript">
function_name (variabl1,variable2)
{
    window.open("url_to_open_relative_or_absolute?v1=" + variable1 + "&v2=" + variable2 + ", "new_window_name"[, "window_features"]);
    return false; // this can be in the calling function, rather than here
}
</script>
 
// the rendered in-page code would like something like... You'll probably want to verify the syntax
<a href="#" onClick="function_name(variable1_value,variable2_value); return false;">my link</a>

Open in new window

0
Kelvin McDanielSr. Developer/ConsultantCommented:
Sorry; didn't see your followup...

Assuming that you've got the javascript function in the <HEAD></HEAD> area of your HTML code already... your SelectedIndexChanged() method content should look something like this... (assumes VS 2005 versions of VB and C#)...

VB Code:
------------------------------------------------
Dim jsString As String = "<script type=""text/javascript"">function_name({0},{1});</script>"
Page.ClientScript.RegisterClientScriptBlock(Page.GetType, "JS_OpenWindow", String.Format(jsString, ListBox1.SelectedValue, variable2_value))
 
 
C# Code:
------------------------------------------------
string jsString = "<script type=""text/javascript"">function_name({0},{1});</script>";
Page.ClientScript.RegisterClientScriptBlock(Page.GetType, "JS_OpenWindow", String.Format(jsString, ListBox1.SelectedValue, variable2_value));

Open in new window

0
kdeutschAuthor Commented:
Hi,
Still using vb.net with asp.net 1.1 (dark ages)
anyway I got something like the follwoing to work, but it has one big problem in that it always opens when you don't want it too and I am trying to figure out how to put in multiple variables to request string.
But it allows me to call out my page width and height and values from left and top.

 lbljavascript.Text = "<script language=javascript>window.open('PersonnelInfo.aspx?id=" & Id & "',SSN=" & Items(2) & "', '', 'width=800 height=600 top=absolute left=150');</script>"
0
kdeutschAuthor Commented:
When I paste this into my   <Head></head> in HTML is blackens out for some reason.

<script language="javascript">
function_name (variabl1,variable2)
{
window.open("Personnel.aspx?v1=" + variable1 + "&v2=" + variable2 + ", "new_window_name"[, "window_features"]);
return false;
}
</script>

How do I get the variables using javascript, sorry do not a lot about javascript, i use sparringly.
0
Kelvin McDanielSr. Developer/ConsultantCommented:
No problem; I understand your pain. ;)

Not sure why it's blacking out on you... I've mocked up (and tested, it works fine) an example that should get you going. Make sure you take the ".txt" off the file extentions inside the archive.
js-opener-example.zip
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kdeutschAuthor Commented:
Hi,
Ok here is what I changed to but I get a Javascript error of error invalid argument and it calls out the script line I put in.

<script language="javascript">
      function ShowItemDetail(Id,SSN)
      {
      opener = window.open("PersonneLInfo.aspx?id=" + Id + "&SSN=" + SSN, "width=800,height=600,scrolling=no");
      return false;
      }
      </script>

here is the code behind
        Dim Id As String = lblHiddenId.Text
        Dim SSN As String = lbPersonnel.SelectedValue
        Dim litShowItem As New Literal
        litShowItem.Text = "<script type=""text/javascript"">ShowItemDetail(" & Id & "," & SSN & ");</script>"
        PlaceHolder1.Controls.Add(litShowItem)

0
kdeutschAuthor Commented:
Hi,
got it done , here are the final parts for asp.net 1.1
HTML
<script language="javascript">
      function ShowItemDetail(Id,SSN)
      {                        
      window.open("PersonnelInfo.aspx?id=" + Id + "&SSN=" + SSN, "", "width=800 height=600 Top=Absolute left=180 scrolling=no");                        
      }
      </script>

<body>
<asp:placeholder id="placeholder1" runat="server"></asp:placeholder>
</body>

Code Behind in listbox change event
        Dim Id As String = lblHiddenId.Text
        Dim SSN As String = lbSoldier.SelectedValue
        Dim litShowItem As New Literal
        litShowItem.Text = "<script type=""text/javascript"">ShowItemDetail(" & Id & "," & SSN & ");</script>"
        PlaceHolder1.Controls.Add(litShowItem)
0
kdeutschAuthor Commented:
Thanks for the help, way better solution than I was originally using.
0
Kelvin McDanielSr. Developer/ConsultantCommented:
Excellent... Congratuluations!

Sorry about the delay; I've been away at meetings. Glad you got it going.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.