Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 1st, 2010, 01:19 PM
Authorized User
Points: 94, Level: 1
Points: 94, Level: 1 Points: 94, Level: 1 Points: 94, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Make Panel visible with Hyperlink

Hi!

Is it possible to make a Panel visible by clicking on a Hyperlink? I know this works well with RadioButtonLists, but cannot figure out if it works with Hyperlinks. If yes, what to I write? I am using Visual Basic.

Cheers
Peter
  #2 (permalink)  
Old August 1st, 2010, 03:45 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You could. However, since HyperLink render as a client side link, you need to pass some state in the URL that tells the panel to hide itself when the page gets requested. E.g.:

SomePage.aspx?HidePanel=True

Then in SomePage.aspx, you access Request.QueryString.Get("HidePanel") and when it contains the value True, you hide the panel.

However, if it's appearance (e.g. text that looks like a link) rather than behavior (e.g. a HyperLink versus another control), I think you're better off using a LinkButton. At the client, it looks like a HyperLink, but it submits back to the server (to the page where it's used) where you can handle its Click event and hide the Panel.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old August 2nd, 2010, 11:42 AM
Authorized User
Points: 94, Level: 1
Points: 94, Level: 1 Points: 94, Level: 1 Points: 94, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

Does this mean I need to have another page with data that loads inside the Panel, like an iframe, or have I misunderstood? Otherwise it sounds like a LinkButton is a better alternative. The way I understand your description is that a LinkButton is a "fake" hyperlink that loads a Panel when you click on it. If so, that's what I was looking for.

Cheers
Peter
  #4 (permalink)  
Old August 2nd, 2010, 11:49 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You misunderstood. a HyperLink simply ends up as a <a href /> element in the browser. By linking it to the same page, with HidePanel=True in the query string you can reload the page and hide the panel. However, indeed you probably want a LinkButton. It also ends up as an <a href /> but uses JavaScript to post back to the same page.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #5 (permalink)  
Old August 10th, 2010, 10:08 AM
Authorized User
Points: 94, Level: 1
Points: 94, Level: 1 Points: 94, Level: 1 Points: 94, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello again,

I inserted a LinkButton in my page with a PostBackUrl;

Code:
<asp:LinkButton ID="LinkButton" runat="server" PostBackUrl="SomePage.aspx">Link</asp:LinkButton>
Then in my CodeBehind i wrote;

Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Panel.Visible = False

If LinkButton.OnClientClick Then
    Panel.Visible = True
End If
With this I get an error message saying the "in-data-string had an incorrect format". What do I need to do, or did I write the wrong script?

Cheers
Peter
  #6 (permalink)  
Old August 10th, 2010, 10:16 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You're mixing up lots of stuff.

First, remove the PostBackUrl property. Then double click the LinkButton in design view to set up a *server side* Click handler. Inside that method, hide the panel.

This all assumes the Panel and LinkButton are in the same page.

OnClientClick is a property that is used to assign a client side JavaScript function that is triggered when the link button is clicked at the client; e.g. before the post back.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #7 (permalink)  
Old August 10th, 2010, 10:36 AM
Authorized User
Points: 94, Level: 1
Points: 94, Level: 1 Points: 94, Level: 1 Points: 94, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I see now what I did wrong, that worked perfectly!

Though, I am making the Panel visible inside the method, as I want it to be invisible from the start. But either way it works perfectly.

Thanks for the help!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Panel in the viewstack not visible Soorej Simon Flex 0 July 16th, 2009 12:40 AM
Hide and make visible scandalous ASP.NET 2.0 Basics 0 May 24th, 2007 08:51 AM
Making a Panel visible in a FormView steve35719 VB How-To 0 June 29th, 2006 07:49 AM
Make visible/invisible stealthdevil Access VBA 6 May 31st, 2006 10:59 AM
Panel.visible shai505 C# 1 April 25th, 2006 05:10 AM



All times are GMT -4. The time now is 12:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.