2014-09-15 5 views
0

먼저, 저는 전문 디자이너이자 독학적인 개발자임을 명심하십시오. 그래서 개발 부분에 대한 지식의 부족을 변명하십시오.ASP 폼의 여러 체크 박스

.ascx와 .ascx.cs 뒤에있는 코드를 사용하여 양식을 만들었습니다. 나는이 양식을 기본 텍스트 필드와 유효성 확인을 위해 잠시 동안 성공적으로 사용 해왔고 한 번 제출 된 선택 사항으로 이메일을 받았다. 나는 최근에 양식에 여러 개의 체크 박스를 추가해야했습니다. 나는 약간의 연구를했고 아래의 코드를 사용했다. 그것은 사이트의 프론트 엔드에서 훌륭하게 작동하지만 양식이 제출되면 나는 내 이메일에있는 옵션 중 하나만 얻습니다. 전자 메일에서 여러 선택 항목을받을 수 있도록 코드 숨김 코드를 어떻게 설정합니까? 이메일 응답 여기

sbFormResult.Append(this.FormatAsTableRow("Send me more info on your Web Solutions:", CheckBoxWebsolutions.Text.ToString())); 
sbFormResult.Append(this.FormatAsTableRow("Send me more info on your Email & Communications 1:", CheckBoxCommunications1.Text.ToString())); 
sbFormResult.Append(this.FormatAsTableRow("Send me more info on your Email & Communications 2:", CheckBoxCommunications2.Text.ToString())); 
sbFormResult.Append(this.FormatAsTableRow("Send me more info on your SharePoint Services:", CheckBoxCollaboration.Text.ToString())); 

그리고있다 :

Test 
Full Name: John Doe 
Company Name: ABC Company 
Email: [email protected] 
Phone Number: 1234567890 
Comments: Testing 
Send me more info on your Web Solutions: Website Design 
Send me more info on your Email & Communications 1: Exchange 
Send me more info on your Email & Communications 2: Hosted Email Encryption 
Send me more info on your SharePoint Services: SharePoint Assessment & Planning 
+0

잘 모르겠습니다. 메일에서 가능한 값을 얻습니다. 그리고 그것은 당신이 원하는 것입니까? – VRC

+0

CheckBoxCommunications1 및 CheckBoxCollaboration이란 무엇입니까? – CrazyPaste

답변

1

당신이 만약

여기
<asp:CheckBoxList ID="CheckBoxWebsolutions" runat="server" AutoPostBack="false" TextAlign="Right" > 
<asp:ListItem Value="Website Design">Website Design</asp:ListItem> 
<asp:ListItem Value="Content Management System">Content Management System</asp:ListItem> 
<asp:ListItem Value="Web App Development">Web App Development</asp:ListItem> 
<asp:ListItem Value="Web Hosting">Web Hosting</asp:ListItem> 
</asp:CheckBoxList> 

가 .ascx.cs 파일입니다 : 여기

은의 .ascx 코드 이 의사 코드를 사용할 수있는 여러 응답을 표시해야합니다 (미안하지만 테스트하지 않음) :

Dim strSelectedWebSolutions as String = "" 

For Each item as ListItem in CheckBoxWebsolutions.Items 
    If item.Selected Then strSelectedWebSolutions = strSelectedWebSolutions & " " & item.Text 
Next item 

sbFormResult.Append(this.FormatAsTableRow("Send me more info on your Web Solutions:", strSelectedWebSolutions)); 
0

질문에 따라 선택한 CheckBox의 텍스트를 수집하려고합니다.

var sbFormResult = new StringBuilder(); 

// Join by comma 
string webSolutions = string.Join(",", 
    CheckBoxWebsolutions.Items.Cast<ListItem>() 
     .Where(x => x.Selected) 
     .Select(x => x.Text)); 

sbFormResult.Append(this.FormatAsTableRow(
    "Send me more info on your Web Solutions:", webSolutions));