Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to send drop down box value/text to another page

Status
Not open for further replies.

veronic

Programmer
Apr 6, 2004
73
0
0
US
I have a grid with populated summary data which depends on drop down selection by departments.
One column in this grid is hyperlink which send three different parameters to detail screen. I am using URL on the HTML side: NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.STATUS_DESC", "../reports/rp_balancesum_det.aspx?stStat="+DataBinder.Eval(Container.DataItem, "STATUS_CODE </asp:HyperLink>

and I get it in next page like:
strStatus = Request.QueryString("stStat")
strAudit = Request.QueryString("stAud")

I need to be able to send drop down value or text to detail screen too and this value is not a part of my dataset.
I cannot use Response.redirect....
How can I do this programatically?
 
hi,

you will have to add javascript to do this. which version of ASP.NET are you using???

Known is handfull, Unknown is worldfull
 
Dim strRedirect As String

strRedirect = "YourForm.aspx?Value=" & Yourddl.SelectedItem.Text

but as vbkris said you would have to use java as well. look into the window.open method



 
thank you very much
Unfortunately I don't know java at all
but i'll try
 
You don't have to use javascript. You could consider using a LinkButton rather than a Hyperlink control and then redirect the user server-side (and append the values to the QueryString that way).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
If you are using .NET 2.0 (i think only there it is available), you can use the PreviousPage method.

Apart from the querystring, you can save it to a session variable.
 
The PreviousPage method wouldn't work in this instance as the user is being redirected to another page (via a link and therefore using the GET method for the values) rather than the form being POSTed to another Page.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>You don't have to use javascript. You could consider using a LinkButton rather than a Hyperlink control and then redirect the user server-side

but that will cost an extra postback!!! that is unneccesary...

Known is handfull, Unknown is worldfull
 
but that will cost an extra postback
It doesn't have to


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ignore my post, it was submitted in error.

but that will cost an extra postback!!! that is unneccesary...
It doesn't have to cause a postback as it could be done with a simple AJAX call. Using the JavaScript method also isn't robust as it won't degrade well to users without it (i.e. it won't work at all!). Using the logic I described, you could post back to the server and then redirect the user. This shouldn't have much of a performance impact and is a lot more robust.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>redirect the user server-side

a sample please?

Becuase when you mention redirect the user server-side, it looked like a postback and then in page_load or button_click event a redirect to the new page...


Known is handfull, Unknown is worldfull
 
A example would be using Response.Redirect


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
i wanted the total example. using javascript you can change the HREF when the onclick event happens.

therefore:
1. Page Loads.
2. User clicks on link.
3. User is taken to the page in the link (with extra querystring attached by JavaScript).

Is this the way you are suggesting:
1. Page Loads.
2. User clicks on button.
3. Page posts back.
4. Response.redirect in Click event of button.

Am i correct???

Known is handfull, Unknown is worldfull
 
I do not use session variable.
Our DBA's do not like it for some reason.
Can someone post a sample how to use LinkButton?
Plus, I had a suggestion to use
ItemDataBound. But I keep getting a lot of errors.
Again, any samples????
Thanks a lot
 
But I do not have a button and I don't need it. That's why I cannot use response.redirect. Unless I can somehow use it not clicking on special button..??
 
hence the extra post back that i was referring to (happening at point 3).


and as far as the JavaScript goes, try this veronic in your link:

OnClickClick="this.href=this.href+'&TheDrpValue='+TheDrp.value"

and at the end of the ASPX file:
<script>
TheDrp=document.getElementById("<%=drpDown.ClientId%>")
</script>

Note:
The script can also be added using code behind...

Known is handfull, Unknown is worldfull
 
hence the extra post back that i was referring to (happening at point 3).
Yes, but did you read my points above?

The logic that I suggested may have a postback and a redirect but it will work in all cases. The drawback is the time taken for a server-side redirect but this should be minimal.

The method you described has three major drawbacks:

1) The ID of the DropDownList may change as ASP.NET can prefix the ID with it's own naming scheme (for example, if Master Pages, User Controls or parent controls are used). This means that you will probably have to register the javascript server-side.

2) You're using a classic style ASP method by including code within ASP tags which are embedded in the HTML portion of the page. ASP.NET is trying to get you away from this style of coding.

3) If the user doesn't have JS, your method will fail entirely.

For the slight performance hit, I know which method I'd choose.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>1) The ID of the DropDownList may change as ASP.NET can prefix the ID with it's own naming scheme (for example, if Master Pages, User Controls or parent controls are used). This means that you will probably have to register the javascript server-side.

thats exactly what ClientID does. and yes you HAVE to register it.


>>2) You're using a classic style ASP method by including code within ASP tags which are embedded in the HTML portion of the page. ASP.NET is trying to get you away from this style of coding.

that was just to give the user an idea of what was happening. read my post above. i mention that IT IS possible to register JS using code behind.

>>3) If the user doesn't have JS, your method will fail entirely.

that is really an old arguement. if JS was disabled then a LOT of ASP.NET features wont work. I think this comment is out of context in this post because this applies to ASP.NET as a WHOLE.


>>For the slight performance hit, I know which method I'd choose.

sure, that that man, that that idea. The entire idea of using JS is to minimise the load on the server however small it is!!!

Known is handfull, Unknown is worldfull
 
hi veronic,

did you try out the JavaScript post???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top