Solved

How to reload the default web-form page after clicked a Link button for a new tab

Posted on 2013-01-29
10
549 Views
Last Modified: 2013-01-30
Hi gurus,

I developed a simple web app with VB ASP.net.

In Form1 page Main.aspx, I have one Link Button control to open a new tab NewTab.aspx, and have one Button control to go to the next page ThankYou.aspx in the same window.

What happened is, if clicked the Link Button at first to open the NewTab.aspx, and closed the NewTab.aspx window, then click on the Button control in the Main.aspx, trying to go next page ThankYou.aspx, but the Button control will still lead to same content of NewTab.aspx.

I used response.redirect("Main.aspx"), it doesn't work. How to refresh the Main.aspx, after clicked on NewTab.aspx?

Your advise, please!
0
Comment
Question by:GaiaGia
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
Use response.redirect with the url of current page.
0
 
LVL 10

Expert Comment

by:Monica P
Comment Utility
use like any below

Response.Redirect("~/MyIntranet/Pages/Default.aspx", false) 
Response.Redirect("~/MyIntranet/Pages/Default.aspx", true) 
or

Response.Redirect("~/MyIntranet/Pages/Default.aspx")

Open in new window


somethimes problem may be due to lack of
lack of a "Handles Me.Load" clause in the Page_load subroutine declaration
0
 

Author Comment

by:GaiaGia
Comment Utility
codecruiser: I did, it still does work. Thanks.

AkilaPalanimuthu: I do have code  "Handles Me.Load" clause in the Page_load  sub declaration. Thanks
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
>codecruiser: I did, it still does work. Thanks.

You mean it does NOT work? When a response.redirect is encountered, statements after that will be ignored. There is only one response and it can only be redirected to one url.
0
 
LVL 41

Expert Comment

by:guru_sami
Comment Utility
GalaGia,
Can you share some code?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:GaiaGia
Comment Utility
For Link Button Control in the Main.aspx to open a new tab NewTab.aspx:

 <p class="MsoNormal" style="margin: 0in 0in 10pt">
            <span><span>
                                <asp:LinkButton ID="LinkButton1" runat="server" Height="18px" OnClientClick="form1.target ='_blank';"
                        PostBackUrl="~/NewTap.aspx" ToolTip="Click on this link" Width="148px" EnableViewState="False">View the notice</asp:LinkButton></span></span></span></span></p>


For Main.aspx and its Button control to open ThankYou.aspx in the same window:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim FileNumber7 As Decimal = Request.QueryString("Val7")
    End Sub


  Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim Username7 As String = Request.QueryString("Val7")
        'Dim FileNumber As Decimal = Request.QueryString("Val7")


        Dim DBconn As New SqlClient.SqlConnection("Data Source=;Initial Catalog=;Integrated Security=True;")
        Dim DBcmd As New SqlClient.SqlCommand
        Dim DBAdap As New SqlClient.SqlDataAdapter
        Dim DS As New DataSet

        DBconn.Open()
        Try
            DBcmd = New SqlClient.SqlCommand("update Temp_ set EnglishCheckbox =@eCheckbox, SpanishCheckbox=@sCheckbox, OtherLanguageCBox=@oCheckbox, languageName=@LanguageName,Signiture=@Signiture,SignitureDate = getdate() where [Number] =@FileNumber ", DBconn)
            DBcmd.Parameters.Add("@eCheckbox", SqlDbType.VarChar).Value = CheckBox1.Checked
            DBcmd.Parameters.Add("@sCheckbox", SqlDbType.VarChar).Value = CheckBox2.Checked
            ...........................
............................
.................................
            DBcmd.Parameters.Add("@FileNumber", SqlDbType.Float).Value = Request.QueryString("Val7")
            DBcmd.ExecuteNonQuery()
        Catch exp As Exception
            Response.Write(exp)
        End Try
        DBcmd.Dispose()
        DBconn.Close()
        DBconn = Nothing

        Response.Redirect("ThankYou.aspx?valfinal=" + Username7)

        ' End Sub
    End Sub
0
 

Author Comment

by:GaiaGia
Comment Utility
I placed the line inside of the subroutine of Button1_Click, it just didn't work:

Response.Redirect("~Main.aspx")
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
>Response.Redirect("ThankYou.aspx?valfinal=" + Username7)
>Response.Redirect("~Main.aspx")

Which page you actually want to redirect to?
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
Comment Utility
The issue is you are using LinkButton and have set it's PostBackUrl.
What you need is use a HyperLink instead of a LinkButton, unless I am missing some part why you need link button.

 <asp:HyperLink ID="HyperLink1" NavigateUrl="~/NewTap.aspx" Target="_blank" runat="server" Height="18px" Width="148px" ToolTip="Click on this link">View the notice</asp:HyperLink>

Open in new window

0
 

Author Comment

by:GaiaGia
Comment Utility
guru_sami: it works now. Thanks a lot.

codeCruiser: in my page Main.aspx, there is a Botton control and a Link Button control. if click on the Link button, it should lead to a new tab NewTab.aspx, if click on the Button, it should open the Thankyou.aspx in the same window.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now