Solved

Client Side Set QueryString from Hidden Field

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

Expert Comment

by:Miguel Oz
Comment Utility
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
Comment Utility

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 35

Expert Comment

by:Miguel Oz
Comment Utility
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
Comment Utility
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 35

Accepted Solution

by:
Miguel Oz earned 500 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now