Solved

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

Posted on 2013-01-29
10
639 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

Industry Leaders: 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!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

724 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