PDA

View Full Version : Page Redirect


justnew
04-07-2005, 11:48 PM
Is this Possible?

I have a header webcontrol with a Search Textbox1 and a submit button1. And I also have searchPage.aspx that is fuctioning ok, the searchPage.aspx also have a Search Textbox2 and a Submit button2.

What I want to adchieve is that when I enter the word in the textbox1 on the header webcontrol and when I hit the submit button1 it should open the Search.aspx and copy the word on the textbox1 to textbox2.
So far on the click event of button1. I have the following code: Response.Redirect("http://www.mytest.net/seach.aspx")In addition I have
Dim textbox2 as textbox
textbox1.Text = textbox2.Text Though it opens the Seach.aspx but the textbox is empty I have to retype my search word again. Can someone help me here. Thanks in advance

snowieken
04-08-2005, 12:16 AM
I am not sure I understand your problem correctly, but I'll give it a go.

If you are redirecting to another page, you need to save the value somehow. Session variables are good for this, and the easiest to use. Do the following in your first page, on the button click event:Session("blah")=textbox1.text
Response.Redirect("http://www.mytest.net/search.aspx")Then, in your second page, make a Page_Load event and do:If Not Session("blah") Is Nothing Then
Textbox2.text = Session("blah")
End IfAgain, I hope I understood you correctly. :)

justnew
04-08-2005, 09:32 PM
Thank you snowieken for the reply. I have tried but it did not work, let me explain again you have a more overview.
I have a header webcontrol which I used for all my pages. In this header I have a textbox1 and a submit button1. I also have a Search.aspx page which has a full search capability in other words this is an independent aspx within my project and it has a textbox named textbox2 and also a submit button name button2. what I want is that when I enter any word I want to search in my textbox1 in the header, when I hit the submit button it should open the Search.aspx and at the same time the search words which I enter in textbox1 should be place on the textbox2. Then I will need to hit the submit button2 to return the search result. Though it could have been nice if I do not need to hit the submit button2 to return the search result. in other words if I could display the search result when the search.aspx loads.

Thanks in advance

razor
04-12-2005, 09:36 AM
Hello justnew,

I think I understand your problem.

You have one part of a page that is a header on every page and has textbox1 and a button to submit that data. Then you have a seperate page named search.aspx which has the searching ability.

In your header, your form code should look something like this (will post the search data in Textbox1 to the search page):

<form name="searchform" action="http://www.mytest.net/search.aspx" method="post">
Search: <input type="text" name="Textbox1">
<input type="submit" name="button1">
</form>


Then in search.aspx, you will need to place this code right up the top of the page (will take the data posted from the previous page and put it into Textbox2):

Textbox2.Text = Request.Form("Textbox1")


Then if you want to make search.aspx submit itself (button2), use the Button2.Submit or javascript to raise the event.

Let me know how this goes.

If this still doesn't work - please post the code of both pages so I know what we are working with.

Have a good day.

justnew
04-16-2005, 09:57 PM
I want to make search.aspx submit itself (button2) Need help

razor
04-17-2005, 02:45 AM
<body onload="javascript:formname.submit();">

Have a good day.

justnew
04-17-2005, 01:22 PM
Thanks razor for the response.
I have tried the code, <body onload="javascript:frmSiteSearch.submit();">
the page keeps looping but nothing happens. I hope you understand what I am trying to archieve.
I have set a default search value in the textbox. Under normal condition I have to click on the search_button in other to get search result. So I want the search_button to fire up when the page loads.

Thanks in advance

miranda
04-18-2005, 04:46 AM
in the onclick event of your web control's button simply use a response.redirect to take the user to the search.aspx page and pass along the value of the textbox1 with it. On search aspx in the page load event assign this value to the textbox2. Next check to see if it is filled in and then call your function. Razor's way of doing it is classic asp and isn't needed in .NET


' on the webcontrol header
Sub Button1_Click(sender As Object, e As EventArgs)
Response.redirect("search.aspx?search=" & textBox1.Text)
End Sub

' on search.aspx
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
TextBox2.Text = Request.Querystring("search")
If TextBox2.Text.Length > 0 Then
'call your function to fill your datagrid or do whatever you want
End If
End If
End Sub

razor
04-19-2005, 02:50 AM
I am unsure what you are trying to attempt, but I suggest to attempt variations of the event, as you may be set on a different object level.

eg) <body onload="javascript:document.frmSiteSearch.submit();">

or.. window.document.frmSiteSearch.submit();

Give that a go, and if you still have no luck, I ask for you to send me the files so I can see exactly what you are trying to do.

justnew
04-19-2005, 10:53 AM
Thank you all for responding to my problem. miranda solution really solved my final problem, namely making the page to submit itself without having to click the search button.
I thank Razor and Miranda for their effort. Great job.

miranda
04-19-2005, 05:11 PM
razor the solutions you have shown makes me wonder if you do anything in asp.net? Because asp.net is TOTALLY different than classic asp.

razor
04-20-2005, 03:22 AM
I don't code in ASP.NET, I saw it in the ASP section, and due to lack of description assumed justnew was coding in ASP.

miranda
04-20-2005, 05:38 AM
That's what I thought. Having a Webcontrol alone told me it was .net but the real kicker was the page having an .aspx extension.

glenngv
04-20-2005, 08:18 AM
Having a Webcontrol alone told me it was .net but the real kicker was the page having an .aspx extension.
And also the data type in the declaration.Dim textbox2 as textbox