Reputation: 671
here is my aspx code for buttons
<div id="navigationButtons">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" CssClass="button submit" Enabled="true" />
<asp:Button ID="btnNext" name="btnNext" Text="NEXT" ToolTip="Next" runat="server" CssClass="button next" TabIndex="0" OnClick="btnNext_Click" Enabled="false"/>
<asp:Button ID="btnPrev" Text="PREV" ToolTip="Previous" runat="server" CssClass="button prev" TabIndex="2" OnClick="btnPrev_Click" Enabled="true"/>
<asp:Button ID="btnExit" Text="EXIT" ToolTip="Exit" runat="server" CssClass="button exit" TabIndex="3" OnClick="btnExit_Click" />
</div>
I am unable to change the attributes from code behind so I browsed for the solution and some blogs suggested using following code in the code behind.
((System.Web.UI.HtmlControls.HtmlElement)Page.Form.FindControl("btnNext")).Style.Add("visible", "false");
I have already tried btnNext.Enabled=false; it is not working. but when I use it there is null exception error in the code. I don't know how to fix this in the above code behind. Any solution is appreciated. thanks.
Upvotes: 0
Views: 2084
Reputation: 305
I just used the aspx
code which you have provided. Note that I don't have the cssClass
specified for the buttons.
Now on Submit Button Click Event, I wrote the following code.
btnNext.Visible = false;
And it disables the Button. So, some other factor is creating problems for you.
First of all, try this on a new page without adding any css
files. It will work.
Then try adding that css
files or classes and check if they are creating problems or not.
Upvotes: 1
Reputation: 1383
You can access the button with it's ID, so you can do something like this:
btnNext.Visible = false;
Have you already tried this?
Upvotes: 1