Solved

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

Posted on 2013-01-29
10
588 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
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 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