开发者

classic asp - response.redirect and response.write problem

The problem if someone types into the search box a开发者_运维知识库 location it goes through to that location page but if they type in a location thats not found or they dont type anything in I need it to redirect back to the homepage (index.asp) and display "whoops we couldnt find that" in the search box (input field)

This is the vb

    Case Else
    response.redirect "index.asp?whoops=whoops we couldnt find that"
End Select

Then in the value of the input field I have

value="<% =whoops %>"

This doesnt work by the way, first is this the best way of doing it because id rather not have the error message in the url. This there away of posting the error as a variable and then calling it into the input field like,

<% =whoops %>


You don't need the error message in the url. Also, whoops won't be available to you as a variable just because it is in the url. You have to look for it in the Request.Querystring collection. What you'd want to do is something more like this on the homepage:

Dim whoops : whoops = ""
If Request.Querystring("whoops") Then
    whoops = "whoops we couldnt find that"
End If

Then you could output <%=whoops %> as the search box's HTML value attribute. This would also prevent people from being able to assign whatever they want to the value of whoops, which is a security vulnerability.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜