Solved

Pass The Value as a query string held in a session variable

Posted on 2006-07-07
9
390 Views
Last Modified: 2008-03-06
I'm trying to open a popUp window by using a hyperlink control

<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="Javascript:var w=window.open('ContactDetails.aspx?ContactID=' + <%= Session[NotifierID] %> + ','','width=980,height=660,resizable=yes');"> Details...</asp:HyperLink>


However instead of ContactID having a value of Session[NotifierID] it is being passed literally as a string ContactID="<%= Session[NotifierID] %>  "

meaning
instead of being passed a value ContactID='8138'
its being passed as ContactID="<%= Session[NotifierID] %>  "

Could you tell me what i'm doing wrong here

Collin
0
Comment
Question by:Collindsouza
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 17058441
try Session["NotifierID"]
0
 
LVL 7

Expert Comment

by:kGenius
ID: 17058444
sorry try: ContactID='<%= Session[NotifierID] %>'
0
 
LVL 5

Author Comment

by:Collindsouza
ID: 17058496
i tied ContactID='<%= Session[NotifierID] %>'

it doesnt work..

it still passes the value of contact id as ContactID=<%= Session[NotifierID] %>  
in my query string :((
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 1

Expert Comment

by:sguerra
ID: 17058506
Well the thing is that the <%  %> asp tags dont work with .net in aspx pages.
To do what you want (since you are using sessions) its better to use a call to the server using a "LinkButton" instead, then on the link's button "click" event you place something like this:

    Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
            Dim popWindow As String
            popWindow = " <script language='javascript'> "
            popWindow += " url = 'ContactDetails.aspx?ContactID="+Session("NotifierID")+"'; "
            popWindow += " newWindow = window.open(url,'WINDETAILS', 'width=980,height=660,resizable=yes,left=0,top=0'); "
            popWindow += " if (window.focus) {newWindow.focus()} "
            popWindow += " </script> "
            Page.RegisterStartupScript("PopupScript", popWindow)
    End Sub


0
 
LVL 7

Expert Comment

by:kGenius
ID: 17058509
Again my excuses:
Try:
asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="Javascript:var w=window.open('ContactDetails.aspx?ContactID=' + <%= Session["NotifierID]" %> + ','','width=980,height=660,resizable=yes');"> Details...</asp:HyperLink>
0
 
LVL 25

Expert Comment

by:nauman_ahmed
ID: 17058519
Its not recommended to set the URL this way. Instead, set the URL parameters from code behind:

.ASPX.VB
-------------
Me.HyperLink2.Attributes.Add("target","_new")
Me.HyperLink2.NavigateURL = "'ContactDetails.aspx?ContactID=" &  Session[NotifierID]

-Nauman.
0
 
LVL 5

Author Comment

by:Collindsouza
ID: 17058597
Thanks nauman,

Your a true Ledgend....
0
 
LVL 5

Author Comment

by:Collindsouza
ID: 17058605
ok tell me.. in the same Attributes.Add how can i set the other properties like 'width=980,height=660,resizable=yes'
0
 
LVL 25

Accepted Solution

by:
nauman_ahmed earned 500 total points
ID: 17058766
The best approach is to write the JavaScript function in ASPX to open the window like the following. Benefit is you have more control over the function:

.ASPX
---------
<script language="javascript">
function OpenContactDetails(ContactID)
{
   window.open("ContactDetails.aspx?ContactID="+ContactID,"MyWindow","width=980,height=660,resizable=yes");
}

In the code behind:

.ASPX.VB
-------------
Me.HyperLink2.Attributes.Add("onclick","javascript: OpenContactDetails("&Session("NotifierID")&");")

Or you can also do like this:

Me.HyperLink2.Attributes.Add("onClick","javascript: window.open('ContactDetails.aspx?ContactID='"&Session("ContactID")&",'MyWindow','width=980,height=660')")
Me.HyperLink2.NavigateURL = "#"

-Nauman.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run time Error 4 47
SQL Login 17 50
tutorial for ebay api 3 34
Question about JQuery and asp.net 3 25
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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