Hi all,
I have a tree list and 2 radio button under this tree list... when i try to find the radio button on my tree list its state has been always checked false.. i have assigned the auto postback .. but its not working it seems..
Source is
Code Behind
I need to set visibility of that text box control while clicking the radio button..
Please help..
Regards,
Prassin
I have a tree list and 2 radio button under this tree list... when i try to find the radio button on my tree list its state has been always checked false.. i have assigned the auto postback .. but its not working it seems..
Source is
<
td
>
<
asp:RadioButton
ID
=
"rbDepPer"
runat
=
"server"
GroupName
=
"dep"
/>
<
telerik:RadNumericTextBox
ID
=
"txtBoxDepPer"
Text='<%# Bind("DepPer") %>' runat="server">
</
telerik:RadNumericTextBox
>
</
td
>
<
td
>
Depreciation Year:
</
td
>
<
td
>
<
asp:RadioButton
ID
=
"rbDepYear"
runat
=
"server"
GroupName
=
"dep"
/>
<
telerik:RadNumericTextBox
ID
=
"txtBoxDepYear"
Text='<%# Bind("DepYear") %>' runat="server"
Width="300px" >
</
telerik:RadNumericTextBox
>
</
td
>
Protected Sub RadTreeList1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.TreeListItemCreatedEventArgs) Handles RadTreeList1.ItemCreated
If TypeOf e.Item Is TreeListEditFormItem AndAlso DirectCast(e.Item, TreeListEditFormItem).IsInEditMode Then
Dim item As TreeListEditableItem = TryCast(e.Item, TreeListEditableItem)
Dim rad1 As RadioButton = DirectCast(item.FindControl("rbDepPer"), RadioButton)
Dim rad2 As RadioButton = DirectCast(item.FindControl("rbDepYear"), RadioButton)
Dim textBox = TryCast(item.FindControl("txtBoxDepPer"), RadNumericTextBox)
Dim textBox2 = TryCast(item.FindControl("txtBoxDepYear"), RadNumericTextBox)
rad1.AutoPostBack = True
rad2.AutoPostBack = True
If rad1.Checked = True Then
textBox.Enabled = True
textBox2.Enabled = False
ElseIf rad2.Checked = True Then
textBox2.Enabled = True
textBox.Enabled = False
End If
End If
End Sub
I need to set visibility of that text box control while clicking the radio button..
Please help..
Regards,
Prassin
9 Answers, 1 is accepted
0

Prassin
Top achievements
Rank 1
answered on 03 Jul 2012, 10:03 AM
Hi all..
On a big trouble.. please help...
Regards
Prassin
On a big trouble.. please help...
Regards
Prassin
0
Hello,
All the best,
Marin
the Telerik team
You can handle the CheckedChanged event of the RadioButton - this way you can perform the necessary action when the button is checked or unchecked.
Private
Sub
rad_CheckedChanged(sender
As
Object
, e
As
EventArgs)
Handles
rbDepPer.CheckedChanged
Dim
rad = TryCast(sender, RadioButton)
Dim
textBox = TryCast(TryCast(rad.NamingContainer, TreeListDataItem).FindControl(
"txtBoxDepPer"
), RadNumericTextBox)
textBox.Visible = rad.Checked
End
Sub
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Prassin
Top achievements
Rank 1
answered on 05 Jul 2012, 09:48 AM
Hi Marin,
how can i get that radio button checked event in code behind... tree list containing that particular radio button...
please help..
Regards
Prassin
how can i get that radio button checked event in code behind... tree list containing that particular radio button...
please help..
Regards
Prassin
0

Princy
Top achievements
Rank 2
answered on 05 Jul 2012, 11:11 AM
Hello,
Try attaching the event as shown below.
C#:
Thanks,
Princy.
Try attaching the event as shown below.
C#:
protected
void
RadTreeList1_ItemCreated(
object
sender, Telerik.Web.UI.TreeListItemCreatedEventArgs e)
{
if
(e.Item
is
TreeListEditFormItem && ((TreeListEditFormItem)e.Item).IsInEditMode)
{
TreeListEditFormItem
item = e.Item
as
TreeListEditFormItem
;
RadioButton rad2 = (RadioButton)item.FindControl(
"RadioButton2"
);
rad2.CheckedChanged +=
new
EventHandler(rad2_CheckedChanged);
}
}
void
rad2_CheckedChanged(
object
sender, EventArgs e)
{
}
Thanks,
Princy.
0

Prassin
Top achievements
Rank 1
answered on 05 Jul 2012, 11:19 AM
Hi Princy..
am work with vb.net... in the case i try to convert this code as vb.. its show an error like "Public Event CheckedChanged (sender as object, e as system.eventArgs)is an event and cannot be called directly use a RaiseEvent statement to Raise an Event"
i dont know what i have to do for this..
Prassin
am work with vb.net... in the case i try to convert this code as vb.. its show an error like "Public Event CheckedChanged (sender as object, e as system.eventArgs)is an event and cannot be called directly use a RaiseEvent statement to Raise an Event"
i dont know what i have to do for this..
Prassin
0

Princy
Top achievements
Rank 2
answered on 06 Jul 2012, 05:07 AM
Hello,
Here is the code in VB.
VB:
Thanks,
Princy.
Here is the code in VB.
VB:
Protected Sub RadTreeList1_ItemCreated(sender As Object, e As Telerik.Web.UI.TreeListItemCreatedEventArgs)
If TypeOf e.Item Is TreeListEditFormItem AndAlso DirectCast(e.Item, TreeListEditFormItem).IsInEditMode Then
Dim item As TreeListEditFormItem = TryCast(e.Item, TreeListEditFormItem)
Dim rad2 As RadioButton = DirectCast(item.FindControl(
"RadioButton2"
), RadioButton)
rad2.CheckedChanged += New EventHandler(rad2_CheckedChanged)
End If
End Sub
Private Sub rad2_CheckedChanged(sender As Object, e As EventArgs)
End Sub
Thanks,
Princy.
0

Prassin
Top achievements
Rank 1
answered on 06 Jul 2012, 05:13 AM
Hi Princy..
Thanks for you replay...
But i am getting the same error..
Please find the attachment...
Regards,
Prassin
Thanks for you replay...
But i am getting the same error..
Please find the attachment...
Regards,
Prassin
0
Hello,
The code converters sometimes do not handle this very well.
Kind regards,
Marin
the Telerik team
The proper way to add an event handler in VB code-behind is the following:
AddHandler
rad2.CheckedChanged,
AddressOf
rad2_CheckedChanged
The code converters sometimes do not handle this very well.
Kind regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Prassin
Top achievements
Rank 1
answered on 07 Jul 2012, 05:44 AM
Hi all,,
When i try to achieve my requirement that time its show and error message ... please look up the code and source .. and also attached error message to this post.. please look up and help...
Aspx:
Code Behind
please find the attachment
Regards,
Prassin
When i try to achieve my requirement that time its show and error message ... please look up the code and source .. and also attached error message to this post.. please look up and help...
Aspx:
<
fromtemplate
>
<
table
>
<
tr
>
<
td
>
Depreciation %:
</
td
>
<
td
>
<
asp:RadioButton
ID
=
"rbDepPer"
runat
=
"server"
GroupName
=
"dep"
/>
<
telerik:RadNumericTextBox
ID
=
"txtBoxDepPer"
Text='<%# Bind("DepPer") %>' runat="server">
</
telerik:RadNumericTextBox
>
</
td
>
<
td
>
Depreciation Year:
</
td
>
<
td
>
<
asp:RadioButton
ID
=
"rbDepYear"
runat
=
"server"
GroupName
=
"dep"
/>
<
telerik:RadNumericTextBox
ID
=
"txtBoxDepYear"
Text='<%# Bind("DepYear") %>' runat="server"
Width="300px" >
</
telerik:RadNumericTextBox
>
</
td
>
</
tr
>
</
table
>
</
fromtemplate
>
Protected Sub RadTreeList1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.TreeListItemCreatedEventArgs) Handles RadTreeList1.ItemCreated
If TypeOf e.Item Is TreeListEditFormItem AndAlso DirectCast(e.Item, TreeListEditFormItem).IsInEditMode Then
Dim item As TreeListEditFormItem = TryCast(e.Item, TreeListEditFormItem)
Dim rad1 As RadioButton = DirectCast(item.FindControl("rbDepPer"), RadioButton)
Dim rad2 As RadioButton = DirectCast(item.FindControl("rbDepYear"), RadioButton)
rad1.AutoPostBack = True
rad2.AutoPostBack = True
AddHandler rad1.CheckedChanged, AddressOf rad1_CheckedChanged
AddHandler rad2.CheckedChanged, AddressOf rad2_CheckedChanged
Dim rad = TryCast(sender, RadioButton)
End If
End Sub
Private Sub rad2_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim rad = TryCast(sender, RadioButton)
Dim textBox = TryCast(TryCast(rad.NamingContainer, TreeListDataItem).FindControl("txtBoxDepPer"), RadNumericTextBox)
textBox.Enabled = rad.Checked
End Sub
Private Sub rad1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim rad = TryCast(sender, RadioButton)
Dim textBox2 As RadNumericTextBox = TryCast(TryCast(rad.NamingContainer, TreeListDataItem).FindControl("txtBoxDepYear"), RadNumericTextBox)
textBox2.Enabled = rad.Checked
End Sub
please find the attachment
Regards,
Prassin