Go Back   Velocity Reviews > General Computer Discussion > Software
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
Old 06-26-2007, 01:56 AM   #1
Smile dynamic validations for checkboxlist and dropdownlist


hi everybody,


1) I am creating a form dynamically so all the controls like textbox, label, dropdownlist are created dynamically according to the values in the database.

2) I am also assigning values to this controls dynamically while page is loaded from the values in database.

3) I am also using masters page, content place holder

Following is my aspx file....

<%@ Page Language="VB" MasterPageFile="~/TemplateAssets/Inside.master" AutoEventWireup="false" CodeFile="FormHandler.aspx.vb" Inherits="Forms_FormHandler" %>

<asp:Content ID="FormContentFrame" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asplaceHolder runat="server" id="FormPlaceHolder" />
<asp:HiddenField ID="HiddenFormID" runat="server" />
<asp:HiddenField ID="HiddenRespondentGUID" runat="server" />
<div align="right" style="padding-top:10px;">

<asp:CompareValidator ID="CompValDate" type="Date" Operator="DataTypeCheck" runat="server"></asp:CompareValidator>
<asp:CompareValidator ID="CompValCurrency" type="Currency" Operator="DataTypeCheck" runat="server"></asp:CompareValidator>
<asp:CompareValidator ID="CompValFloat" type="Double" Operator="DataTypeCheck" runat="server"></asp:CompareValidator>
<asp:CustomValidator runat="server" ID="ValCheckBoxList" ClientValidationFunction="isChecked()"></asp:CustomValidator>&nbsp;
<asp:Button ID="Val" runat="server" Text="Validate" OnClick="valcheckbox"/>&nbsp;
<asp:TextBox ID="testing" runat="server" />
<asp:Button ID="SubmitButton" runat="server" Text="Submit" CssClass="SubmitButton" />
</div>

</asp:Content>


-----------------------------------------------------------------------
Following is my code behind file for creating dynamic controls and assigning values to it from database..

snap of code:-


Case "CheckBoxList"
'LHS Column
Dim r As New TableRow()
Dim c As New TableCell()
Dim Label As New Label
Label.Text = record.Item("Label")
c.Controls.Add(Label)
c.VerticalAlign = VerticalAlign.Top
r.Cells.Add(c)
'RHS Column
c = New TableCell()
Dim CheckboxList As New CheckBoxList
Dim ResponseOptions As String = record.Item("ResponseOptions").ToString
Dim ResponseOptionsArray As String() = Nothing


ResponseOptionsArray = ResponseOptions.Split(",")
CheckboxList.ID = record.Item("FieldGUID")
Dim ResponseOption As String
For Each ResponseOption In ResponseOptionsArray
CheckboxList.Items.Add(ResponseOption)

c.Controls.Add(CheckboxList)
Next ResponseOption
CheckboxList.SelectedIndex = 0
CheckboxList.ID = "checkboxlist"
c.Controls.Add(l2)
l2.Text = "Please Select One Of The CheckBox :- "
'Checkbox
c.Controls.Add(CheckboxList)


3)--- And I am creating sub pro ( onclick the validation should fire )

Public Sub valcheckbox(ByVal sender As Object, ByVal e As System.EventArgs) Handles Val.Click

l3.Text = "hello000000000000000000"
l2.Text = " hello2000000000000000"
testing.Text = "hello300000000000000000000"

'Dim userSelectionList As CheckBoxList = CType(FindControl("checkboxlist"), CheckBoxList)

'If userSelectionList.SelectedIndex = -1 Then
' l1.Text = "Please Select One Of The Option In CheckBoxList "
'End If

'Dim userSelectionList2 As DropDownList = CType(FindControl("dropdownlist"), DropDownList)

'If userSelectionList2.SelectedIndex = 0 Then
' l2.Text = "Please Select Any Item Other Then -Select- "
'End If

End Sub


----->4) The main program is when i click on button it doesnt get fire it simply can't display label testing,l2,l3 just first line in the sub proce

so i dont think its getting side ..?

Also can any one please check my logic for validation dyamic is proper or not..? beacause all data and controls are created dynamic ..?

Thanking you all....
Regards
Mrugesh.


mrugesh_dulera
mrugesh_dulera is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
DropdownList in gridview visj4u Software 0 04-27-2007 01:11 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46