[Mono-list] ASP.NET object troubles

Shawn Vose mono@programmerforrent.com
Sun, 12 Dec 2004 16:56:46 -0500


On your aspx page do you have the buttons running at the server?

<asp:Button ID="InfoButton" Runat="server"/>


Raul Carolus wrote:

> Greetings all.
>
> I have a aspx, with codebehind, that i'm trying to get tabcontrol-like 
> behavior on.  I have everything working, except for the visual effects 
> to determine what tab is selected.
>
> I'm using buttons as the tabs, and setting their CssClass to indicate 
> whether the button is selected or not.  I use a Session variable to 
> store what button is selected.
>
> However, when the page loads or does a postback,  I'm always getting 
> null references when working with the buttons.
>
> Here's some of my code:
>
> public class StudentsPage : Page
>     {
>         private long studId;
>         protected System.Web.UI.WebControls.Button InfoButton, 
> BeltButton, InstButton, CertsButton, TrnyButton, BioButton;
>         protected Button selectedButton;
>
>
>         private void Page_Load(Object Sender, System.EventArgs e)
>         {
>             Console.Write("Page_Load\n");
>            
>             if(IsPostBack)
>             {
>             Console.Write("Postback\n");
>             }
>             InfoButton.CssClass="Button";
>             BeltButton.CssClass="Button";
>             InstButton.CssClass="Button";
>             CertsButton.CssClass="Button";
>             TrnyButton.CssClass="Button";
>             BioButton.CssClass="Button";
>            
>             if((string)Session["student_tab"] == "info")
>                 InfoButton.CssClass="SelectedButton";
>
> If I comment out the code referening the buttons, everything else 
> works fine.
>
> I've tried putting the code in various procedures, OnInit, 
> OnPreRender, etc, all with the same results.
>
> Is there something I'm doing wrong?  I've worked for four days on this 
> and am at my wits end.  Can someone lend a hand?
>
> Thanks,
>
> Raul
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>