Hi everyone
I want to create RadWindow to help a user enter a value of a textbox. So basically on a form I will have a RadTextBox and a button to show the RadWindow. The RadWindow will have a grid that is filterable with all the options the user can select. When he selects thes value, it needs to close the RadWindow and populate the Textbox with the selected value.
Are there any examples on this?
Thanks
I want to create RadWindow to help a user enter a value of a textbox. So basically on a form I will have a RadTextBox and a button to show the RadWindow. The RadWindow will have a grid that is filterable with all the options the user can select. When he selects thes value, it needs to close the RadWindow and populate the Textbox with the selected value.
Are there any examples on this?
Thanks
6 Answers, 1 is accepted
0
Accepted
Hi Jako,
The following demo is quite similar: http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx. It shows how data can be returned from a RadWIndow and set in a Textbox. It is done with JavaScript and if you need this on the server you can find the following article useful on invoking the JavaScript method from the code-behind: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-javascript-from-server-side.html.
Regards,
Marin Bratanov
Telerik
The following demo is quite similar: http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx. It shows how data can be returned from a RadWIndow and set in a Textbox. It is done with JavaScript and if you need this on the server you can find the following article useful on invoking the JavaScript method from the code-behind: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-javascript-from-server-side.html.
Regards,
Marin Bratanov
Telerik
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
Jako
Top achievements
Rank 1
answered on 31 May 2013, 09:26 AM
That is exactly what I was looking for. Need to tweak it for my purposes, but its great.
Thanks Marin
Thanks Marin
0
Jako
Top achievements
Rank 1
answered on 31 May 2013, 01:51 PM
Hi Marin
Just a last question. Is there away to enable drag/drop from the window? I have the radWindow, but would like to be able to drag the content of the RadListBox into one of the text boxes on the initial form.
I have attached a image to give you an example.
Thanks.
Just a last question. Is there away to enable drag/drop from the window? I have the radWindow, but would like to be able to drag the content of the RadListBox into one of the text boxes on the initial form.
I have attached a image to give you an example.
Thanks.
0
Hi Jako,
The RadListBox supports DragAndDrop functionality, so that you can achieve the desired functionality:
C#:
JavaScript:
You can also find useful ListBox - Drag-and-drop online demo and OnClientDropped help article.
Regards,
Danail Vasilev
Telerik
The RadListBox supports DragAndDrop functionality, so that you can achieve the desired functionality:
- On the server by handling the OnDropped event handler. For example:
ASPX:
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
VisibleOnPageLoad
=
"true"
>
<
ContentTemplate
>
<
telerik:RadListBox
ID
=
"RadListBox1"
runat
=
"server"
Width
=
"200px"
Height
=
"300px"
OnDropped
=
"RadListBox_Dropped"
EnableDragAndDrop
=
"true"
>
<
Items
>
<
telerik:RadListBoxItem
Text
=
"item1"
Value
=
"0"
/>
<
telerik:RadListBoxItem
Text
=
"item2"
Value
=
"1"
/>
<
telerik:RadListBoxItem
Text
=
"item3"
Value
=
"2"
/>
</
Items
>
</
telerik:RadListBox
>
<
asp:TextBox
ID
=
"Textbox2"
runat
=
"server"
/>
</
ContentTemplate
>
</
telerik:RadWindow
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
/>
protected
void
RadListBox_Dropped(
object
sender, RadListBoxDroppedEventArgs e)
{
if
(TextBox1.ClientID == e.HtmlElementID)
{
TextBox1.Text = String.Empty;
foreach
(RadListBoxItem item
in
e.SourceDragItems)
{
TextBox1.Text += item.Text +
", \n"
;
}
if
(TextBox1.Text.Length > 0)
TextBox1.Text = TextBox1.Text.TrimEnd(
new
char
[] {
','
,
' '
,
'\n'
});
}
}
- On the client by handling the OnClientDropped event handler. For example:
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
VisibleOnPageLoad
=
"true"
>
<
ContentTemplate
>
<
telerik:RadListBox
ID
=
"RadListBox1"
runat
=
"server"
Width
=
"200px"
Height
=
"300px"
OnClientDropped
=
"OnClientDroppedHandler"
EnableDragAndDrop
=
"true"
>
<
Items
>
<
telerik:RadListBoxItem
Text
=
"item1"
Value
=
"0"
/>
<
telerik:RadListBoxItem
Text
=
"item2"
Value
=
"1"
/>
<
telerik:RadListBoxItem
Text
=
"item3"
Value
=
"2"
/>
</
Items
>
</
telerik:RadListBox
>
<
asp:TextBox
ID
=
"Textbox2"
runat
=
"server"
/>
</
ContentTemplate
>
</
telerik:RadWindow
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
/>
<script type=
"text/javascript"
>
function
OnClientDroppedHandler(sender, eventArgs) {
eventArgs.get_htmlElement().value = eventArgs.get_sourceItem().get_text();
}
</script>
You can also find useful ListBox - Drag-and-drop online demo and OnClientDropped help article.
Regards,
Danail Vasilev
Telerik
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
Jako
Top achievements
Rank 1
answered on 13 Jun 2013, 09:16 AM
Hi Danail
The drag and drop works, but I can only drop it onto a control in the RadWindow.
I want to drag it from the RadWindow onto the ASPX page that opended it.
If you look at the attached image in the previous post, I basically want to drag the "AFP - Ceramic Arts..." value onto the BIC Code 1 Textbox of the parent window.
Any ideas?
Thank you.
The drag and drop works, but I can only drop it onto a control in the RadWindow.
I want to drag it from the RadWindow onto the ASPX page that opended it.
If you look at the attached image in the previous post, I basically want to drag the "AFP - Ceramic Arts..." value onto the BIC Code 1 Textbox of the parent window.
Any ideas?
Thank you.
0
Hi Jako,
Note that RadWindow offers two states for loading its content inside ContentTemplate and NavigateUrl. When the ContentTemplate property is used, the RadWindow acts as naming container, so that its control are still part of the page. If, however, the NavigateUrl property is used, its content is rendered inside iframe, which created a separate document in turn.
It seems that you are setting the NavigateUrl property of the RadWindow and that is why the communication between the page loaded within the RadWindow and the main page cannot be done as the content in the RadWindow is an iframe. This is described in Window - ContentTemplate vs. NavigateUrl online demo.
Regards,
Danail Vasilev
Telerik
Note that RadWindow offers two states for loading its content inside ContentTemplate and NavigateUrl. When the ContentTemplate property is used, the RadWindow acts as naming container, so that its control are still part of the page. If, however, the NavigateUrl property is used, its content is rendered inside iframe, which created a separate document in turn.
It seems that you are setting the NavigateUrl property of the RadWindow and that is why the communication between the page loaded within the RadWindow and the main page cannot be done as the content in the RadWindow is an iframe. This is described in Window - ContentTemplate vs. NavigateUrl online demo.
Regards,
Danail Vasilev
Telerik
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 the blog feed now.