user control, css, and redirect

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a navigation user control navig.ascx that redirects to respective
pages based on webcontrols.linkbutton clicks using response.redirect.

I would like to control the look and feel of those link buttons. Once I
click the button, I would like to make it bold using instructions like

linkbutton.font.bold=true

This works as long as its NOT followed by response.redirect

For example:

linkbutton.font.bold=true;
response.redirect("mypage.aspx");

if I take out the response line, this works, with response line in the code,
the instruction does get executed but some how link button does not get
bolded.
"mypage.aspx" does host navig.ascx user control as other navigated pages.

Please help.
Thanks
Trisha
 
Trisha:
You are getting things confused.

You are setting the bold property of a control to true, then going to
another page. The control (linkbutton) doesn't survive through a
redirect...you create a new instance.....

If you want this boldedness value to survive postbacks and links you should
use the :visited attribute of CSS.
http://www.blooberry.com/indexdot/css/syntax/pseudo/pclassvisited.htm


<asp:linkbutton id="x" runat="server" CssClass="someClass" ... />

and your css should look like:

someClass:visited{
font-weight:bold;
}


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
Karl,

When I apply this CssClass="someClass" to all the linkbuttons on the ascx
page,
all the linkbuttons are bolded even though they are not clicked.
 
That's because those links have been visited in the past, which is how the
:visited pseudo-css-class works.

It dawns on me that you want the link to be bolded for the new page the user
is on to indicate to the user that this is the page you are on. In other
words, you want it bolded once and only once.

To do so, you should make the navigation control self-aware of what page it
is on and which linkbutton to bold. You shouldn't do it on the eventhandler
of the linkbutton click, but rather on the page_load of the user control.

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
Karl,

Thanks for the answer. Please let me know if you know how to make the user
control aware what page its on. I will research it in the mean time.

Thanks
 
Karl,

I used the following line of code to get to the parent.

Parent.Page.ToString();

thanks again for all your help. I am good to go.
 
Back
Top