LinkButton click event not firing

M

Mel

I have a website that allows the user to generate a new quote. When
they are finished creating the quote, it brings them to the final page
(called the Goodbye.aspx page) which just states the quote has been
submitted and an email will arrive to them shortly.

I added a "Home" link button on this page which will return them to
the website's home page. I want to clear out 10 session variables
(contact name, ship to address, city, state, zip, etc.) when they
click the Home button so it's ready for a new quote, however the
LinkButton_click event is never fired. How do I clear the session
variables from this Goodbye page?
 
G

Guest

I have a website that allows the user to generate a new quote. When
they are finished creating the quote, it brings them to the final page
(called the Goodbye.aspx page) which just states the quote has been
submitted and an email will arrive to them shortly.

I added a "Home" link button on this page which will return them to
the website's home page. I want to clear out 10 session variables
(contact name, ship to address, city, state, zip, etc.) when they
click the Home button so it's ready for a new quote, however the
LinkButton_click event is never fired. How do I clear the session
variables from this Goodbye page?

How does your button look like?

Should be similar to this

<asp:LinkButton ID="..." Text="Home" runat="server"
OnClick="LinkButton_click"></asp:LinkButton>

and the event

protected void LinkButton_click(object sender, EventArgs e)
{
....
}

to ensure that it's working, add a debug info

Response.Write("Hello...");
 
M

Mel

How does your button look like?

Should be similar to this

<asp:LinkButton ID="..." Text="Home" runat="server"
OnClick="LinkButton_click"></asp:LinkButton>

and the event

protected void LinkButton_click(object sender, EventArgs e)
{
...

}

to ensure that it's working, add a debug info

Response.Write("Hello...");

It currently looks like this. I posted the click event code too (but
it's not firing). Did I mention that I am a new user? So I hope it's
something easy.


'file: BMQQuoteGoodBye.aspx
<asp:LinkButton ID="lbutHome" runat="server" PostBackUrl="~/
FSMPTechHome.aspx"
Style="z-index: 104; left: 36px; position: absolute; top:
95px">Home</asp:LinkButton>

'file: BMQQuoteGoodBye.aspx.vb
Protected Sub lbutHome_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lbutHome.Click
Session("OrdNum") = Nothing
Session("ProjName") = Nothing
Session("ShipAddr1") = Nothing
Session("ShipAddr2") = Nothing
Session("ShipCity") = Nothing
Session("ShipSt") = Nothing
Session("Customer") = Nothing
Session("CusContact") = Nothing
Session("CusPhone") = Nothing
Session("ShipZip") = Nothing
Session("PriceAdj") = Nothing
End Sub
 
G

Guest

It currently looks like this. I posted the click event code too (but
it's not firing). Did I mention that I am a new user? So I hope it's
something easy.

'file: BMQQuoteGoodBye.aspx
<asp:LinkButton ID="lbutHome" runat="server" PostBackUrl="~/
FSMPTechHome.aspx"
Style="z-index: 104; left: 36px; position: absolute; top:
95px">Home</asp:LinkButton>

'file: BMQQuoteGoodBye.aspx.vb
Protected Sub lbutHome_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lbutHome.Click
Session("OrdNum") = Nothing
Session("ProjName") = Nothing
Session("ShipAddr1") = Nothing
Session("ShipAddr2") = Nothing
Session("ShipCity") = Nothing
Session("ShipSt") = Nothing
Session("Customer") = Nothing
Session("CusContact") = Nothing
Session("CusPhone") = Nothing
Session("ShipZip") = Nothing
Session("PriceAdj") = Nothing
End Sub- Hide quoted text -

- Show quoted text -

Mel,

when you set the PostBackUrl, you post the page directly to
FSMPTechHome.aspx

Try to remove PostBackUrl="~/FSMPTechHome.aspx" and add to the end of
lbutHome_Click() function the following line

Response.Redirect("~/FSMPTechHome.aspx")

Hope it helps
 
M

Mel

Mel,

when you set the PostBackUrl, you post the page directly to
FSMPTechHome.aspx

Try to remove PostBackUrl="~/FSMPTechHome.aspx" and add to the end of
lbutHome_Click() function the following line

Response.Redirect("~/FSMPTechHome.aspx")

Hope it helps- Hide quoted text -

- Show quoted text -

Okay thanks. Like this? Sorry to be a pain but I have never used
the redirect method before.

Protected Sub lbutHome_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lbutHome.Click
Response.Redirect("~/FSMPTechHome.aspx")

End Sub
 
G

Guest

Okay thanks. Like this? Sorry to be a pain but I have never used
the redirect method before.

Protected Sub lbutHome_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lbutHome.Click
Response.Redirect("~/FSMPTechHome.aspx")

End Sub- Hide quoted text -


Yes, it's correct:

HOW TO: Use Response.Redirect in ASP.NET with Visual Basic .NET
http://support.microsoft.com/kb/312063
 
M

Mel

Yes, it's correct:

HOW TO: Use Response.Redirect in ASP.NET with Visual Basic .NEThttp://support.microsoft.com/kb/312063- Hide quoted text -

- Show quoted text -

Thanks for your help, it works like a charm. I posted the code below
in case someone else can benefit from it. Apparently clicking the
Home link button calls the Page_Load event where I happened to be
writing the quote record to the database so I had to enclose the
Page_Load code with an IF statement "If Not IsPostBack Then" to ensure
the database is only written once. Yep, that redirect method will be
my new "favorite" friend. Oh just imagine the possiblities!

Protected Sub lbutHome_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lbutHome.Click
'Clear session variables before returning to the HOME page.
Session("OrdNum") = Nothing
Session("ProjName") = Nothing
Session("ShipAddr1") = Nothing
Session("ShipAddr2") = Nothing
Session("ShipCity") = Nothing
Session("ShipSt") = Nothing
Session("Customer") = Nothing
Session("CusContact") = Nothing
Session("CusPhone") = Nothing
Session("ShipZip") = Nothing
Session("PriceAdj") = Nothing
Response.Redirect("~/FSMPTechHome.aspx")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top