Solved

Client Side Set QueryString from Hidden Field

Posted on 2011-03-01
6
1,192 Views
Last Modified: 2012-08-14
Hi EE,

I have an href control in my aspx code.  I want to redirect with a querystring to another page.
The querystring needs to be developed from an hidden field on the form.
How do I do this?

Thanks
<a href='<%# "Portfolio.aspx?StylistID="+StylistID.Value %>' />

Open in new window

0
Comment
Question by:Sheritlw
[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
  • 2
6 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 35011891
what about making onclick event instead of href:
<a onclick=showNewLink(); />

function showNewLink()
{
  window.open('Portfolio.aspx?StylistID='+StylistID.Value , '_blank', 'height=200,width=400,status=yes,resizable=yes');
}

For more info on window open, check:
http://msdn.microsoft.com/en-us/library/ms536651(v=vs.85).aspx
0
 

Author Comment

by:Sheritlw
ID: 35011931

I would rather use client side.
I've already tried response.redirect on the server also, but it didn't work.

Thanks


Response.Redirect("Portfolio.aspx?StylistID=" & Me.StylistID.Value & "")

Open in new window

0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 35013893
My solution is client side (javascript) and it is opening a new window.
If you need to open the link in the same window, the javascript method should be:
function showNewLink()
{
  window.location = "Portfolio.aspx?StylistID="+StylistID.Value;
}

Note: In your server code, have you checked that the StylistID.Value is assigned in the client code only?
For more info in hidden value usage, check:
http://www.daniweb.com/forums/thread26184.html

0
 

Author Comment

by:Sheritlw
ID: 35014009
I've checked that there is a value in hidden field.
I'm not sure what you mean by window.location??
I just want to open another page.  In the page load of the page I want to open, I request the query string.
When I walk through the code, Response.Redirect("Portfolio.aspx?StylistID=" & Me.StylistID.Value & "")
I get the error Operator '==' incompatible with operand types 'Int32' and 'Object' before the page load fires on the page I want to open.

Thanks
0
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 35048240
For comment 1:
The code posted is javascript code: (You have to add that to your web site, see http://www.daniweb.com/forums/thread26184.html)

function showNewLink()
{
  window.location.href = "Portfolio.aspx?StylistID="+StylistID.Value;
}

For   window.location.href explanation, check:
http://www.w3schools.com/jsref/prop_loc_href.asp

For comment 2:
Response.Redirect("Portfolio.aspx?StylistID=" & Me.StylistID.Value)
also put a breakpoint and tell me what Me.StylistID.Value has been set.


0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

752 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