.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Clearing a form with response.redirect

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net

I have the following default.aspx.vb

Imports System.Data.SqlClient
Imports System.Data

Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub
    Public Sub InsertRow()
        Dim myConnectionString As String = "Initial Catalog=mdr;Data Source=xxxxxxx;uid=xxxxxx;password=xxxxxxxx;"

        Dim myConnection As New SqlConnection(myConnectionString)
        Dim commandText As String = _
        "insert into Exceptions (employeenumber, exceptiondate, starttime, endtime, duration, code, approvedby) " & _
        "values(@employeenumber, @exceptiondate, @starttime, @endtime, @duration, @code, @approved)"

        Using connection As New SqlConnection(myConnectionString)
            Dim command As New SqlCommand(commandText, connection)

            command.Parameters.Add("@employeenumber", SqlDbType.VarChar)
            command.Parameters("@employeenumber").Value = OperatorDropdown.SelectedItem.Text

            command.Parameters.Add("@exceptiondate", SqlDbType.DateTime)
            command.Parameters("@exceptiondate").Value = exceptiondateInput.Text

            command.Parameters.Add("@starttime", SqlDbType.DateTime)

View Complete Post

More Related Resource Links

Response.Redirect slow


I'm in the middle of migrating servers and on the new server Response.Redirect is extremely slow. It takes around 20 seconds for the browser to get the redirect. This is something that was quick on the existing server. It's an ASP.NET 2.0 application, both servers are running IIS6.

Additionally, if I "manually" do the redirect, it's fast. For example:

Existing way:


takes around 20 seconds on the new server

New way:

Response.Status = "302 Moved Temporarily";
Response.AddHeader("Location", url);

is fast on the new server.

Any ideas why Response.Redirect would be so slow on the new server?



I need to open a new window with Response.Redirect, Is it possible?

Adding a cookie to a response.redirect vs. httpWebRequest


Hello, I will try to be as clear as I can be.  I'm sure this question has been asked but I can't find a suitable answer for this particular situation.

I need to be able to redirect the browser to a new 3rd party page while at the same time supplying a cookie required for some form of authentication on the 3rd party site.

I have managed to get this to work in the following manner:


'SessionID is predetermined by another HttpWebRequest/Response  

Dim sessionCookie As New Cookie("ezproxy", sessionID.Substring(1), "/", ".someother.site")

Dim CookieJar As New CookieContainer


rRequest = HttpWebRequest.Create("where I want to go")

rRequest.CookieContainer = CookieJar

rRequest.Method = "GET"


'Make the request and get the response.

rResponse = rRequest.GetResponse()


'Save cookie(s)

If (rResponse.Cookies.Count <> 0) Then

For Each cook

Exit Popup and response.redirect

Hi, I have a requirement to show an Exit Popup on one of our processing pages. I am showing the exit popup by registering a client side javascript like window.onbeforeunload = ShowExitPopUp(); The popup executes fine if you close the window, or try to type in a different URL. However the issue is that my processing page is also performing a "Response.Redirect" on the server side once the process completes. When response.redirect happens the exitpopup also shows up. Is there a way to have the exit popup not show up in that case? Since my server side code is running through an UpdatePanel, so I have tried registering the following, in an attempt to remove ExitPopup from client side. However this doesn't work since server side redirection happens before end request. Sys.WebForms.PageRequestManager.getInstance().add_endRequest(RemoveExitPopup); Has anyone faced a similar situation and handled it?

Unwanted form clearing

Hi all, Some users have somtetimes problem with unwanted reload and clearing form after they do some action. For instance they fill grid with some data then click "add another position" and form reload and lose its data. There is no rule cuz they can add 10 position and on 11 the error occur or even 100 and on 101 the error appear. The form looks as you click "CTRL + R" or go to it again through menu.  This is not only one form but generally it may appear on all forms. Any ideas what may cause this error? I am not sure if it is a WCF problem but on other apps I have't noticed such a problem.

Response.Redirect("URL") and target="_blank"

in codebehid  I use Response.Redirect(http://www.google.com.hk/) I want the google page is open in a new Win ,did not cove my page, in html we can use target="_blank" How can I hadle it in Redirect? Thank you

What is the difference between Server.Transfer & response.Redirect()

Hello Friends,This is the very favourate question available on every interview questions site.I have searched for it. But didnt get the satisfactory practical difference between these two.Please show me the difference between this two through a working sample demo.Please ilustrate it through a simple sample.

Post the SAML Response in an HTML form to the assertion consumer service

Hi,   Can anyoner please help me in how to post the SAML Response in an HTML form to the assertion consumer service. I have generated the saml reponse and want to send the same to the re-directing url.  

Response.Redirect in new browser window

   protected void ddlPrint_Changed(object sender, EventArgs e)     {         if (ddlPrint.SelectedValue == "All Agenda Items")         {             Response.Redirect(string.Format("{0}?{1}", SettingsRepository.ReportingURL,                                             Utils.EncryptQueryString("ReportName=AgendaItem.rpt")));         }How can I open following report in new browser window using response.redirect? Thx   protected void ddlPrint_Changed(object sender, EventArgs e)    {        if (ddlPrint.SelectedValue == "All Agenda Items")        {            Response.Redirect(string.Format("{0}?{1}", SettingsRepository.ReportingURL,                                            Utils.EncryptQueryString("ReportName=AgendaItem.rpt")));        }}

Response.Redirect in C# for page to page parameter passing

Looking for examples of this, but can't find anything specific. I'm new to ASP.NET, and C# at the same time... so I'm struggling to get it right...  Thanks, Nick


Hi..Is it possible to go to the previous page from wherever we are currently is, using the Response.Redirect()?

Response.Redirect is not working with UpdatePanel

 Response.Redirect is not working with UpdatePanelafter migrating a web site to ASP.NET version 4.please help urgent

Posting form data and receiving a response

Hey everyone,I have an application that needs to post data to a url on the web and then receive an xml response.  I have an HTML form (provided by vendor) that posts the data correctly, however when clicking the submit button the page is redirected to the post url and the xml is displayed in the browser.  I need to do this on a postback within an existing asp.net project.  Basically, the user will fill out the form, the form data will post to the url, the xml response will be received, and the appropriate values will be displayed on the screen. I've found a bunch of examples for doing this but I just can't seem to get my head around it.  Can anyone point me in the right direction or explain how I should go about this?  Thanks for your help!Will

Response.Redirect problem in Google Chrome

I'm building an ASP.NET 3.5 webapplication using VB.NET, and I'm having problems redirecting to another URL when using Google Chrome. Other browsers like IE and Firefox are fine.My data entry forms all have an OK and an Cancel button, which are both handled server-side. The Cancel button just redirects back to the originating page, while the OK button will add or update a database record and then redirect to the originating page.The redirect to the originating page is done by calling the following shared sub on a general utilities class in my appication: Shared Sub Redirect(ByVal p_sURL As String) Dim l_sURL As String = p_sURL.ToLower If Left(l_sURL, 1) = "~" Then Dim l_oControl As New System.Web.UI.Control l_sURL = l_oControl.ResolveUrl(l_sURL) End If If Left(l_sURL, 1) <> "/" Then If Left(l_sURL, 7) <> "http://" AndAlso Left(l_sURL, 8) <> "https://" Then l_sURL = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) & wsUtils.SiteRoot & l_sURL End If End If HttpContext.Current.Response.Redirect(l_sURL) 'HttpContext.Current.Response.Redirect(l_sURL, False) End Sub As you can see, I've tried using the extra argument in the Response.Redirect call, but that

How to redirect infopath form in web browser

Hi,     Am working in Infopath 2007, i published my Infopath form to a form library, currently am opening my form using Web browser. I want to redirect my form after submitting form to library, Is it possible to redirect the infopath form?, How. If possible is this redirect will support in web browser?

Response.Redirect in c# class.

Can you tell me the code of  private void btnnext_Click(object sender, EventArgs e)         {                               }   I am writing response.redirect but then also i am getting error can you plz helpThanks & Regard Aarti.Thakkar (nemo)

Clearing ValidationSummary when form returns a download request



Here's my setup:

Simple mvc page with a few controls that includes a validation summary area. 

Once the fields are completed there's a download button.

If I enter something invalid, as expected, my controller code updates the UI with the appropriate error.  However, if I then correct the error, and then click the download button a file is downloaded, but the UI never gets updated - presumeably since there's no update on the view.

Any ideas on a way around this - perhaps some javascript code.  Just wondering what's the best practice here?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend