By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,652 Members | 1,697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,652 IT Pros & Developers. It's quick & easy.

response.redirect (this page?)...short and sweet way to do this?

P: n/a
I have a 'cancel' button that should reload the current page. Ie, reset the
page back to it's initial state.

Is the best way to do this to simply have the event handler for that button
redirect the page to itself?

If so, is there a short-and-sweet way to write that out? Or do I need to
first grab the URL and parse it?

I don't want to hardcore the url as this might be used in different
locations.

-Darrel
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You should be able to use Response.Redirect(".") or
Response.Redirect(Request.URL)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"darrel" <no*****@hotmail.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl...
I have a 'cancel' button that should reload the current page. Ie, reset the page back to it's initial state.

Is the best way to do this to simply have the event handler for that button redirect the page to itself?

If so, is there a short-and-sweet way to write that out? Or do I need to
first grab the URL and parse it?

I don't want to hardcore the url as this might be used in different
locations.

-Darrel

Nov 18 '05 #2

P: n/a
> Response.Redirect(Request.URL)

Oh. Duh. Missed the obvious on that one! ;o)

Thanks!

-Darrel
Nov 18 '05 #3

P: n/a
Why not just use an HTML Cancel button and save the round trip?

Dale

"darrel" <no*****@hotmail.com> wrote in message
news:eY*************@TK2MSFTNGP09.phx.gbl...
Response.Redirect(Request.URL)


Oh. Duh. Missed the obvious on that one! ;o)

Thanks!

-Darrel

Nov 18 '05 #4

P: n/a

"Dale" <da************@msndotcomNot.Net> wrote in message news:uX*************@TK2MSFTNGP10.phx.gbl...
Why not just use an HTML Cancel button and save the round trip?

Dale


That might not work correctly: if postbacks have happened
(server side validators, autopostback, ...) then the values
of that latest postback will be restored, not the real initial values!

Hans Kesting
Nov 18 '05 #5

P: n/a
darrel wrote:
I have a 'cancel' button that should reload the current page. Ie, reset the
page back to it's initial state.

Is the best way to do this to simply have the event handler for that button
redirect the page to itself?

If so, is there a short-and-sweet way to write that out? Or do I need to
first grab the URL and parse it?

I don't want to hardcore the url as this might be used in different
locations.

-Darrel

Hello,

Hope this helps (see attached text file)

ChiefDnd

Private Sub btnCancel_Reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel_Reset.Click
'/////////////////////////////////////////////////////////////////
' Clear the form (Textbox and DropDownList)
'/////////////////////////////////////////////////////////////////
Dim objC As Control
For Each objC In Page.Controls
Dim objType As Type = objC.GetType()
If objType.FullName = "System.Web.UI.HtmlControls.HtmlForm" Then
Dim objF As HtmlForm = CType(objC, HtmlForm)
Dim objWC As Control
For Each objWC In objF.Controls
Dim objWCType As Type = objWC.GetType()
If objWCType.FullName = "System.Web.UI.WebControls.TextBox" Then
Dim objTB As TextBox = CType(objWC, TextBox)
objTB.Text = ""
End If
If objWCType.FullName = "System.Web.UI.WebControls.DropDownList" Then
Dim objDDL As DropDownList = CType(objWC, DropDownList)
objDDL.SelectedIndex = 0
End If
Next objWC
End If
Next objC
lblMessage.Visible = False
'/////////////////////////////////////////////////////////////////
' Refill the form as needed
'/////////////////////////////////////////////////////////////////
SetupPage()
End Sub
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.