Reputation: 671
Here is my aspx code for button
<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>
here is my code behind
protected void btnSubmit_Click(object sender, EventArgs e)
{
string selectedAnswers = presentationManager.GetSelectedAnswer(pnlQuestionOptions);
if (!String.IsNullOrEmpty(selectedAnswers))
{
questAnsInfo = new QuestionAnswerInfo();
questAnsInfo = persistanceManager.GetPersistanceDataForModification();
questAnsInfo.Answer = selectedAnswers;
Question question = persistanceManager.GetQuestionData(presentationManager.GetCourse().Title, Convert.ToInt32(questAnsInfo.Index));
string feedBack = presentationManager.GetFeedBack(question, selectedAnswers);
lblFeedback.Text = feedBack;
feedbackPanel.Visible = feedBack== string.Empty ? false : true;
questAnsInfo.Weight = presentationManager.GetWeight(question, selectedAnswers);
if (persistanceManager.ModifyToPersistance(questAnsInfo))
{
}
btnSubmit.Enabled = false; //not working
btnNext.Enabled = true; //not woriking
}
}
In above webform code behind I have set the property of the buttons accordingly. But there is no change in property in aspx page. What should I do to make it work?
Upvotes: 0
Views: 7271
Reputation: 1
These responses are all very helpful! I found success by putting asp:button in an update panel - but ONLY after calling the [updatepanelcontrol].update() method. Important detail.
Upvotes: 0
Reputation: 671
Actually the update panel was not working in my case. I have placed my buttons inside update panel and now it has worked.
Thanks for answering.
Upvotes: 2
Reputation: 171
try this: i think this will work...
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
btnSubmit.disabled= true;
btnNext.disabled= false;
}
or you can also try:
btnSubmit.Attributes["disabled"] = "disabled";
hope this will help you.
Upvotes: 2