5 Answers, 1 is accepted
0
Hi Paul,
There should be no problem to add client script inside the FormTemplate of your RadTreeList. You could use RadInput controls and attach their OnBlur client event to check the value and if needed, disable the controls in question. What problems exactly are you encountering in this scenario?
Greetings,
Tsvetina
the Telerik team
There should be no problem to add client script inside the FormTemplate of your RadTreeList. You could use RadInput controls and attach their OnBlur client event to check the value and if needed, disable the controls in question. What problems exactly are you encountering in this scenario?
Greetings,
Tsvetina
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
Paul
Top achievements
Rank 1
answered on 08 Nov 2011, 03:02 PM
I am new to these controls. I am using the EditFormSetting of type Template as a pop-up. Since it is a pop-up I assume the code has to be with the controls, preferable client-side. How to you put java script in the template definition?
0
Hello Paul,
Even with a popup edit form, all parts of the page are accessible from inside the edit form, it does not open a separate window. So, you can directly put a script block outside or inside the edit form and trigger it either on text changed event of a textbox or on button click of the submit (insert/update) button. For example:
And javascript outside of the edit form:
This would result in the submit button being disabled if 'Larry' is input in the textbox.
I hope this helps.
Kind regards,
Tsvetina
the Telerik team
Even with a popup edit form, all parts of the page are accessible from inside the edit form, it does not open a separate window. So, you can directly put a script block outside or inside the edit form and trigger it either on text changed event of a textbox or on button click of the submit (insert/update) button. For example:
<
FormTemplate
>
<
table
>
<
tr
class
=
"EditFormHeader"
>
<
td
colspan
=
"2"
style
=
"font-size: small"
>
<
b
>Employee Details:</
b
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"vertical-align: top"
>
<
table
class
=
"module"
>
<
tr
>
<
td
>
First Name:
</
td
>
<
td
>
<
asp:TextBox
ID
=
"TextBox1"
Text='<%# Bind("LastName") %>' runat="server" onchange="checkName(this);">
</
asp:TextBox
>
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator1"
runat
=
"server"
ControlToValidate
=
"TextBox1"
ErrorMessage
=
"Should enter value"
/>
</
td
>
</
tr
>
.............................................
<
telerik:RadButton
ID
=
"btnUpdate"
Text='<%# (Container is TreeListEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is TreeListEditFormInsertItem) ? "PerformInsert" : "Update" %>'
Icon-PrimaryIconCssClass="rbOk">
</
telerik:RadButton
>
And javascript outside of the edit form:
<telerik:RadCodeBlock ID=
"RadCodeBlock1"
runat=
"server"
>
<script type=
"text/javascript"
>
function
checkName(sender) {
if
(sender.value ==
'Larry'
) {
$find(sender.id.replace(
'TextBox1'
,
'btnUpdate'
)).set_enabled(
false
);
//$find is used for script controls like ours
}
}
</script>
</telerik:RadCodeBlock>
This would result in the submit button being disabled if 'Larry' is input in the textbox.
I hope this helps.
Kind regards,
Tsvetina
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
Paul
Top achievements
Rank 1
answered on 10 Nov 2011, 02:48 PM
Thanks for the response,
0
Paul
Top achievements
Rank 1
answered on 11 Nov 2011, 04:48 PM
I got the enabling/disabling of the controls working in the EditFormSettings Template. I just had to make some minor changes to the code you provided. I specified the script block without a RadCodeBlock and I had to use document.getElementById instead of $find.
Thanks for the help,
Paul