Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Client Side Set QueryString from Hidden Field

Posted on 2011-03-01
6
Medium Priority
?
1,219 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
  • 3
  • 2
5 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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

782 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