Convert asp.net code to jquery/div
in Using jQuery UI
•
12 years ago
i m posting here sample code ,can any one can please convert this code behind code to jquery based ,but let me tell u what does it actually doing
it create div on run time as many div's as radiobuttonlist number(1 to 7 ) clicked says. div
include table then htmlrow and then htmlcell that htmlcell hold server side control like textboxes ,validation etc etc
include table then htmlrow and then htmlcell that htmlcell hold server side control like textboxes ,validation etc etc
here is the code behind which need to be convert
-
Protected
Sub RadioButtonList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList2.SelectedIndexChanged 'Response.Write(RadioButtonList2.SelectedValue) Dim index As Integer For index = 1 To Me.RadioButtonList2.SelectedValue Dim newdiv As New HtmlGenericControl("div") 'newdiv.EnableViewState = True Dim ht As New HtmlTable()ht.BgColor =
"cyan"ht.ID =
"mytable" & index 'ht.EnableViewState = Trueht.Width =
"100%"ht.CellSpacing =
"0"ht.CellPadding =
"0"ht.Border = 0
Dim htr, htr1, htr2 As New HtmlTableRow() Dim cell, htc, htc1, htc2, htc3, htc4, htc5, htc6, htc7, htc8 As New HtmlTableCell() Dim name_tb As New TextBox() Dim sal_ddl As New DropDownList 'validator Dim name_req As New RequiredFieldValidator Dim tel_req As New RequiredFieldValidator Dim email_req As New RequiredFieldValidatorname_tb.ID =
"name_tb" & indexsal_ddl.ID =
"sal_ddl" & indexname_req.ID =
"name_req" & indextel_req.ID =
"tel_req" & indexemail_req.ID =
"email_req" & index 'name_tb.EnableViewState = True 'sal_ddl.EnableViewState = True 'tel_req.EnableViewState = Truesal_ddl.Items.Add(
"MR")sal_ddl.Items.Add(
"Ms")sal_ddl.Items.Add(
"Mrs") Dim Tel_tb1 As New TextBoxTel_tb1.ID =
"Tel_tb1" & index 'Tel_tb1.EnableViewState = Truename_tb.TextMode = TextBoxMode.SingleLine
Dim email_tb1 As New TextBoxemail_tb1.ID =
"email_tb1" & indexemail_tb1.TextMode = TextBoxMode.SingleLine
htc.InnerText =
"Name : "htc.Width =
"20%"htc.Align =
"Left"htc1.Controls.Add(sal_ddl)
htc1.Width =
"10%"htc2.Width =
"70%"htc2.Align =
"left"htc2.Controls.Add(name_tb)
htc2.Controls.Add(name_req)
htr.Controls.Add(htc)
htr.Controls.Add(htc1)
htr.Controls.Add(htc2)
ht.Controls.Add(htr)
name_req.ControlToValidate =
"name_tb" & indexname_req.Display = ValidatorDisplay.Dynamic
name_req.ErrorMessage = (
"Please Enter name of attendenes") 'make 2nd rowhtc3.InnerText =
"Telephone : "htc3.Width =
"20%"htc3.Align =
"Left"htc4.InnerHtml =
"<strong></strong>"htc4.Width =
"10%"htc5.Width =
"70%"htc5.Align =
"left"htc5.Controls.Add(Tel_tb1)
htc5.Controls.Add(tel_req)
htr1.Controls.Add(htc3)
htr1.Controls.Add(htc4)
htr1.Controls.Add(htc5)
ht.Controls.Add(htr1)
tel_req.ControlToValidate =
"Tel_tb1" & indextel_req.Display = ValidatorDisplay.Dynamic
tel_req.ErrorMessage = (
"Please Enter Phone") 'make 3rd rowhtc6.InnerText =
"Email : "htc6.Width =
"20%"htc6.Align =
"Left"htc7.InnerHtml =
"<strong></strong>"htc7.Width =
"10%"htc8.Width =
"70%"htc8.Align =
"left"htc8.Controls.Add(email_tb1)
htc8.Controls.Add(email_req)
htr2.Controls.Add(htc6)
htr2.Controls.Add(htc7)
htr2.Controls.Add(htc8)
ht.Controls.Add(htr2)
email_req.ControlToValidate =
"email_tb1" & indexemail_req.Display = ValidatorDisplay.Dynamic
email_req.ErrorMessage = (
"Please Enter Email") 'Add a blank rowcell.ColSpan = 3
cell.InnerHtml =
"<br/>" Dim row As New HtmlTableRowrow.Cells.Add(cell)
ht.Rows.Add(row)
newdiv.Controls.Add(ht)
newdiv.Attributes.Add(
"table", "ht")newdiv.Attributes.Add(
"Style", "border-bottom :#ccc solid 0px")newdiv.Attributes.Add(
"style", "height:23px")newdiv.Attributes.Add(
"style", "padding-left:20px") Me.PlaceHolder1.Controls.Add(newdiv)PlaceHolder1.EnableViewState =
True Next End Sub
Thanks ,any urgent reply is higly appreciated
1