Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
AnswerMessage Removed Pin
19-Mar-14 4:09
professionalN_tro_P19-Mar-14 4:09 
GeneralRe: Xsd2Code Bug Pin
OriginalGriff19-Mar-14 6:02
mveOriginalGriff19-Mar-14 6:02 
GeneralRe: Xsd2Code Bug Pin
Richard MacCutchan19-Mar-14 7:17
mveRichard MacCutchan19-Mar-14 7:17 
Questionconver speech to the text Pin
mohammad_mgh99118-Mar-14 22:16
mohammad_mgh99118-Mar-14 22:16 
AnswerRe: conver speech to the text Pin
Richard MacCutchan18-Mar-14 22:29
mveRichard MacCutchan18-Mar-14 22:29 
GeneralRe: conver speech to the text Pin
mohammad_mgh99118-Mar-14 23:12
mohammad_mgh99118-Mar-14 23:12 
AnswerRe: conver speech to the text Pin
Bernhard Hiller19-Mar-14 0:37
Bernhard Hiller19-Mar-14 0:37 
QuestionHow many dynamic check boxes are checked Pin
NYCABR18-Mar-14 7:42
NYCABR18-Mar-14 7:42 
Hello,
We have a web page dynamically loaded check boxes (depends on how many records in database).
What i need is to make sure the user checks only 5 check boxes. And if he checks the 6th one, give him a message that he can only check 5.
ASP:
Please select up to five:
<asp:Repeater runat="server" ID="rptCandidats" >
        <ItemTemplate>
             <div>
 <asp:checkbox id="chResponse" runat="server"  AutoPostBack="True" OnCheckedChanged="Check_Clicked"></asp:checkbox>
<%# Eval("ResText")%> <a href="<%#Eval("ResLink")%>" class="moreinfo">   More Info</a>
<asp:HiddenField ID="ResId" runat="server" Value ='<%#Eval("ResponId")%>' />                           </div>
</ItemTemplate>
</asp:Repeater>

I tried to use OnCheckedChanged event, but it doesn't work.
Below is a C# code:
protected void Check_Clicked(Object sender, EventArgs e)
       {
           int checkedCount = 0;
           foreach (RepeaterItem r in rptCandidats.Items)
           {
              CheckBox cb = (CheckBox)r.FindControl("chResponse");
               if (cb.Checked)
               {
                   checkedCount += (sender as CheckBox).Checked ? 1 : -1;
               }
           }
           if (checkedCount > 5)
           {
               System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE="JavaScript">alert(\"Only Up to five candidates can be selected.\")</SCRIPT>");
           }

       }

Any ideas how can i achieve it?
AnswerRe: How many dynamic check boxes are checked Pin
BillWoodruff18-Mar-14 22:08
professionalBillWoodruff18-Mar-14 22:08 
GeneralRe: How many dynamic check boxes are checked Pin
NYCABR19-Mar-14 3:10
NYCABR19-Mar-14 3:10 
Questionc# - accessing a web service using Soap XML request client through tls authentication Pin
Member 1067924618-Mar-14 2:00
Member 1067924618-Mar-14 2:00 
QuestionHow to create Textbox with ellipse button Pin
ahmed_one18-Mar-14 1:31
ahmed_one18-Mar-14 1:31 
AnswerMessage Closed Pin
18-Mar-14 3:09
professionalBillWoodruff18-Mar-14 3:09 
GeneralRe: How to create Textbox with ellipse button Pin
Wayne Gaylard18-Mar-14 3:49
professionalWayne Gaylard18-Mar-14 3:49 
GeneralRe: How to create Textbox with ellipse button Pin
BillWoodruff18-Mar-14 4:43
professionalBillWoodruff18-Mar-14 4:43 
GeneralRe: How to create Textbox with ellipse button Pin
ahmed_one18-Mar-14 5:19
ahmed_one18-Mar-14 5:19 
AnswerRe: How to create Textbox with ellipse button Pin
Ravi Bhavnani18-Mar-14 5:26
professionalRavi Bhavnani18-Mar-14 5:26 
GeneralRe: How to create Textbox with ellipse button Pin
ahmed_one18-Mar-14 5:31
ahmed_one18-Mar-14 5:31 
GeneralRe: How to create Textbox with ellipse button Pin
Ravi Bhavnani18-Mar-14 5:39
professionalRavi Bhavnani18-Mar-14 5:39 
GeneralRe: How to create Textbox with ellipse button Pin
BillWoodruff18-Mar-14 6:07
professionalBillWoodruff18-Mar-14 6:07 
GeneralRe: How to create Textbox with ellipse button Pin
Ravi Bhavnani18-Mar-14 6:33
professionalRavi Bhavnani18-Mar-14 6:33 
AnswerRe: How to create Textbox with ellipse button Pin
Ravi Bhavnani18-Mar-14 5:42
professionalRavi Bhavnani18-Mar-14 5:42 
GeneralRe: How to create Textbox with ellipse button Pin
ahmed_one18-Mar-14 5:51
ahmed_one18-Mar-14 5:51 
GeneralRe: How to create Textbox with ellipse button Pin
Ravi Bhavnani18-Mar-14 6:06
professionalRavi Bhavnani18-Mar-14 6:06 
AnswerMSDN solution Pin
Ravi Bhavnani18-Mar-14 6:08
professionalRavi Bhavnani18-Mar-14 6:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.