Solved

Client Side Set QueryString from Hidden Field

Posted on 2011-03-01
6
1,186 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to prevent website from publishing with errors 9 62
Footer for each row on Gridview 2 41
Why use this lambda? 12 60
Validating textboxes in red square borders. 2 33
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

761 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