[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2006-07-07
9
Medium Priority
?
395 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
[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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 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