Last post Oct 22, 2007 08:36 AM by GavDraper
Oct 21, 2007 07:47 PM|deshg|LINK
I am a php programmer originally and am just helping a friend of mine update their website that they paid a designer (well that's what he called himself!) to do ages ago. I have built the whole site but am having problems on the most basic thing! I have
a page which querys an MS SQL database and takes url variables to query it, so it takes the value of keyword= and perpage= (eg from
www.site.com?keyword=test&perpage=15) to define a keyword to search for and the number of entries to display on a page. This works perfectly.
All i want is a very simple form (or whatever you want to call it) to pass these variables from another page on my site, so if it was an html form i would just have a form, a text box for the keyword and a pull down box with a few choices for perpage, then
a submit button and a post method. Simple. All done.
This cross posts to the correct page but just has <%=txtKeyword.Text%> as the keyword variable. I have read numerous methods of putting functions within the script tags of the page to read the variables,
but i am using a master page so only have one script tag for all pages. I also read all asp buttons use get as their method? I have then read about using the Page.PreviousPage method to retrieve controls from the previous page, which i would rather not do
as i want to just pass them simply through the url so as to allow for bookmarking specific searches etc. I am ultimately very confused and think i am missing something as i can't believe that there isn't a simple way of just passing the textbox values as variables
through the url. :)
I would really, really appreciate any help anyone could give me, i've been messing about with this and reading up on it for ages and i am stumped, even though i completely appreciate i'm sure i'm being incredibly stupid and i really should have started
at the beginning, as i say i'm just trying to help a friend of mine get his website back up.
Thank you so much for any help that you might be able to give, this is beginning to drive me crazy :),
Oct 22, 2007 08:36 AM|GavDraper|LINK
You should be able to achieve this by creating a new aspx page, put 2 textboxes on it and a button. In the onclick event for the button add the following code
Response.Redirect("www.site.com?keyword=" & txtKeyword.text &
"&perpage=" & txtPerPage.text)
obviously the textboxes will need to be called txtKeyword and txtPerPage, this should achieve what you need.