Note that there are some explanatory texts on larger screens.

plurals
  1. POchanging CSS class for object sender control
    primarykey
    data
    text
    <p>i'm making a workbook creator in C#.net ( using visual studio )</p> <p>the book is build from the text part and the question part.</p> <p>all the answers for the question are inside the text and the user need to click on the right answer. if he's right then the word become green and if he's wrong it become red.</p> <p>i'm creating the clickeable text with LINKBUTTON, i gave the link button CssStyle class and after the user clicking the word i want to change the class for this link to a different class.</p> <p>this is the code i using for creating the linksbutton:</p> <pre><code> public void createQusetion(Panel lefttext, Panel question, string text, string questionText, string answer) { string[] Qbuttonstext = text.Split(' '); _numberWords = Qbuttonstext.Length; for (int i = 0; i &lt; _numberWords; i++) { LinkButton answerButton = new LinkButton(); if (Qbuttonstext[i] == answer) { answerButton.ID = "answer" + i; } else { answerButton.ID = "word" + i.ToString(); } answerButton.Text = Qbuttonstext[i].ToString() + " "; answerButton.CssClass = "textbuttonB4"; answerButton.Click += new EventHandler(checkAnswer); lefttext.Controls.Add(answerButton); } } </code></pre> <p>and for the checking the question:</p> <pre><code> private void checkAnswer(object sender, System.EventArgs e) { for (int i = 0; i &lt; _numberWords; i++) { if (((Control)sender).ID.ToString() != null) { if (((Control)sender).ID.ToString() == "answer" + i.ToString()) { ((Control)sender).CssClass = "textbuttonRight"; } else { ((Control)sender).CssClass = "textbuttonwrong"; } } } } </code></pre> <p>the VS2010 giving me misatake for the : ((Control)sender).CssClass .</p> <p>what is the right way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload