Solved

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

Posted on 2013-01-29
10
610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 83

Expert Comment

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

Expert Comment

by:Monica P
ID: 38834202
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
ID: 38835193
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38835274
>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
ID: 38835298
GalaGia,
Can you share some code?
0
 

Author Comment

by:GaiaGia
ID: 38835816
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
ID: 38835855
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
ID: 38835877
>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
ID: 38836212
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
ID: 38836852
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Groupbox Control ? 2 29
How to filter by key press ? 6 57
How can I add google maps in vb.net. 2 22
Check only one toolstripmenu item 12 30
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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