Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pass URL value without changing displayed search results

Posted on 2011-02-24
11
Medium Priority
?
435 Views
Last Modified: 2012-05-11
I will explain this as best I can. When a user types in a search field (ASP Textbox field) and presses enter a list of search results are displayed if there is a match. The search results display in the second half of the page. A video will play in the top half of the page but not until a querystring is passed to the page. The querystring value comes from the list of displayed search results. When a user clicks on results from the search (ASP Hyperlink) the querystring value is passed to the same page he/she is on and a video starts playing. My major problem is when I pass the querystring value I do not want to lose the list of search results. It looks like in ASP.net the page refreshes each time you pass a new value. It's not optional to make the user click the back button to see the orginal search results. I'm assuming it has something to do with maintaining session state but I am no expert. YouTube and many other sites do this similar functionality so I figure it must be possible in ASP.Net. Please provide any guidance that you can. If you can help please also include the full code instead of a reference to the code if at all possible
0
Comment
Question by:derrekdeveloper
[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
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34974931
Why not just save the HTML of the tag that contains the search results and then repopulate it? If it's all asp.net you should be able to this very easily.

So use jquery and getelementbyid, then get innerhtml, then send your querystring, on the postback dump the html back in.

Or if it's all .net controls just do it in a routine before you post the querystring.
0
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34974983
Here is an example:

client = new WebClient();
String htmlCode = client.DownloadString("http://born2code.net");

Open in new window

0
 
LVL 9

Accepted Solution

by:
rawinnlnx9 earned 2000 total points
ID: 34974988
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Expert Comment

by:mayank_joshi
ID: 34978952
use link button instead of hyperlink and on postback of hyperlink do something like:-

Response.Redirect("page1.aspx?videoid=" & videoid & "&search1=" &  txtsearch1.text & "&search2=" & txtsearch2.text)

Open in new window

0
 
LVL 4

Expert Comment

by:abhinayp
ID: 34982619
After u click a link in ur page loads completely. So its like opening a new page.
So, after u display results the first time, u need to save the search results in a session and rebind the list/grid with the results after page loads.
Or even save the textbox parameters in a session n get bake the results again.

Lemme know if i wasnt clear.
0
 

Author Comment

by:derrekdeveloper
ID: 34982756
abhinayp:

That's exactly what I was thinking but didn't really know how to do it. I figured I need to save the search results in a session or....

I thought about if I could capture the value from the orginal search performed and then resubmit it when I pass the querystring parameter. So if a user submitted 'bicep' in their search criteria I would capture 'bicep' and submit it again. It would mean going to the database again but the user would still have the original search results on the page. I'm sure this is absolutely not the most efficient way to do this.

The better approach seems to be this:So, after u display results the first time, u need to save the search results in a session and rebind the list/grid with the results after page loads.

Problem is I don't know how to do either one.
0
 
LVL 4

Expert Comment

by:abhinayp
ID: 34983371
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Not Session("Results") Is Nothing Then
                If Not Request.QueryString("urQueryString") Is Nothing Then
                    Dim dt As New DataTable
                    dt = Session("Results")
                    GridView1.Datasource = dt
                    GridView1.DataBind()
                End If
            End If
        End If
    End Sub

    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim dt As New DataTable
        dt = GetResults(txtName.Text)
        Session("Results") = dt

        GridView1.Datasource = dt
        GridView1.DataBind()

    End Sub
0
 

Author Comment

by:derrekdeveloper
ID: 34983504
This is where I am now. I am using the following code to get the value of the text box from the submitted form. It is correct because I see the value displayed in the label.

Dim displayValues As New StringBuilder()
        Dim postedValues As NameValueCollection = Request.Form
        Dim nextKey As String
        For i As Integer = 0 To postedValues.AllKeys.Length - 1
            nextKey = postedValues.AllKeys(i)
            If nextKey.Substring(0, 2) <> "__" Then
                displayValues.Append("<br>")
                displayValues.Append(nextKey)
                displayValues.Append(" = ")
                displayValues.Append(postedValues(i))
            End If
        Next
        Label3.Text = displayValues.ToString()

In the following code I actually pass the query string value which I have to do. What I think I need to do is modify the code below to not only pass the querystring value at it is doing but also get the value that the label is displaying and submit that as a form value if that is possible.

<asp:HyperLink ID="HyperLink45" runat="server"
 ForeColor="White"
 ImageUrl='<%# Eval("videoplaymed") %>'
 
 NavigateUrl='<%# String.Format("~/search.aspx?eid={0} ", Eval("eid")) %>'
 >
</asp:HyperLink>
0
 
LVL 4

Expert Comment

by:abhinayp
ID: 34983693
Just making sure if i understood correctly.

displayValues contains ur final results and u are displaying it using Label3. Right?
0
 
LVL 4

Expert Comment

by:abhinayp
ID: 34983736
If thats the case,  chk this
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Not Session("Results") Is Nothing Then
                If Not Request.QueryString("eid") Is Nothing Then

                    Label3.Text = Session("Results").ToString()

                End If
            End If
        End If
    End Sub

    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click

        'Some code here

        Dim displayValues As New StringBuilder()
        Dim postedValues As NameValueCollection = Request.Form
        Dim nextKey As String
        For i As Integer = 0 To postedValues.AllKeys.Length - 1
            nextKey = postedValues.AllKeys(i)
            If nextKey.Substring(0, 2) <> "__" Then
                displayValues.Append("<br>")
                displayValues.Append(nextKey)
                displayValues.Append(" = ")
                displayValues.Append(postedValues(i))
            End If
        Next
        Label3.Text = displayValues.ToString()
        Session("Results") = Label3.Text

        'Some more code


    End Sub

Open in new window

0
 

Author Comment

by:derrekdeveloper
ID: 34983839
Correct. I grabbed the code from the ASP.Net Forum. After looking at your code though I'm pretty sure that will work also. Let me list out the page flows.

The site is www.GoLiveFitness.com

1. From the Default.aspx page and about 5 others a user can search for exercises by entering values in a field named search whish is a asp.net textbox.

2. On the search results page called Search.aspx the results display.

3. Currently a user clicks on a image from the search results and a new 320 x 240 browser opens and starts playing a video (JW Player) which has received a querystring value passed when the user clicked on the image.

4. We have signed up 600 users in three weeks but we have received many, many complaints about playing the video in a new window and I agree. I then decided it must be possible to keep all of the image results that pass the querystring information displayed on the page even as the user selects and plays different videos.

5. My first test was to try and capture the textbox value and at least store it in a label to verify it which I did.

6. Now I'm trying to figure out how to pass the captured value from the text box and pass the querystring value from the images from the search reults.

7. I have to different SQLDataSources and Stored Procedures running on the page. One is looking for the query string to play the video. The other one is looking for the textbox value that produces the search results.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

636 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