This is a migrated thread and some comments may be shown as answers.

[Solved] RadWindowManager - PromptTemplate

2 Answers 286 Views
Window
This is a migrated thread and some comments may be shown as answers.
Kurt Boeckman
Top achievements
Rank 1
Kurt Boeckman asked on 11 Jan 2010, 11:15 PM
Greetings,

I need to provide users with a prompt requiring them to enter data into a text box and also select a single item from a drop down list box.  I found the following article in the Telerik Forums:

http://www.telerik.com/support/kb/aspnet-ajax/window/custom-radprompt-for-radwindow.aspx

Its easy enough to make work.  However, I need to dynamically populate the drop down list box with values taken from server side code.  I have not found a clever way of doing this.  I tried creating a custom template in code via this article:

http://www.telerik.com/help/aspnet-ajax/window_dialogschangingthedialogtemplates.html

The above article does not describe how you could populate the drop down list box using server code.  I'm out of ideas.  Any suggestions would be helpful.  Thanks.

2 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 12 Jan 2010, 07:22 AM
Hello Kurt,

RadWindowManager's templates accept pure HTML only - they cannot be used with server-side controls. What I can suggest in scenario like yours is to use a RadWindow like a controls container and to implement the desired logic by using it as a dialog.


Regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kurt Boeckman
Top achievements
Rank 1
answered on 12 Jan 2010, 06:03 PM
Thank you for responding.  I decided to use the following code:

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
<PromptTemplate> 
<div class="windowpopup radprompt">           
    <div class="dialogtext">  
    {1}               
    </div>    
    <div> 
        <script type="text/javascript">  
            function radwindowprompt_detectenter(id, ev, input) {  
                if (!ev) ev = window.event;  
                if (ev.keyCode == 13) {  
                    var but = input.parentNode.parentNode.getElementsByTagName("A")[0];  
                    if (but) {  
                        if (but.click) but.click();  
                        else if (but.onclick) {  
                            but.focus(); var click = but.onclick; but.onclick = null; if (click) click.call(but);  
                        }  
                    }  
                    return false;  
                }  
                else return true;  
            }  
 
            function closePrompt(winid) {  
                var listNameInput = document.getElementById('listNameInput');  
                if (listNameInput) {  
                    var listName = listNameInput.value;  
                }  
                var select = document.getElementById('select' + winid);  
                if (select) {  
                    var selectselectedValue = select.options[select.selectedIndex].value;  
                }  
 
                var confirmWnd = $find(winid);  
                if (selectedValue) {  
                    confirmWnd.close(listName + ';' + selectedValue);  
                }  
                else{  
                    confirmWnd.close(listName);  
                }  
            }        
 
        </script> 
        <input id="listNameInput" onkeydown="return radwindowprompt_detectenter('{0}', event, this);" type="text"  class="dialoginput" value="{2}" /> 
          
        <%= ConfigureOptions() %>   
    </div>            
    <div> 
        <!-- <a onclick="$find('{0}').close(true);"  class="radwindowbutton" href="javascript:void(0);" ><span class="outerspan"><span class="innerspan">##LOC[OK]##</span></span></a> --> 
        <onclick="closePrompt('{0}');" class="radwindowbutton" href="javascript:void(0);">     
                            <span class="outerspan"><span class="innerspan">##LOC[OK]##</span></span></a>    
        <onclick="$find('{0}').close(false);" class="radwindowbutton"  href="javascript:void(0);"><span class="outerspan"><span class="innerspan">##LOC[Cancel]##</span></span></a> 
    </div> 
</div>        
</PromptTemplate></telerik:RadWindowManager> 

In the code behind, I implemented the ConfigureOptions method as follows:

    protected string ConfigureOptions()  
    {  
        StringBuilder toReturn = new StringBuilder();  
 
        if (!Page.IsPostBack)  
        {  
            if (UserAdministration.IsAdmin())  
            {  
                toReturn.Append("<div id='DivDestinationNodes' class='dialogtext'></br>Select Destination.<select id='select{0}'>");  
 
                foreach (RadTreeNode node in this.ListsTreeView.GetAllNodes())  
                {  
                    //Get the selected node type  
                    NodeType nodeType =  
                            EnumUtilities.EnumValueOf<NodeType>(  
                                node.Attributes["NodeType"].ToString());  
 
                    switch (nodeType)  
                    {  
                        case NodeType.Team:  
                        case NodeType.User:  
                            //Add node   
                            toReturn.AppendFormat("<option value='{0}'>{1}</option>", node.Value, node.Text);  
                            break;  
                    }  
                }  
 
                toReturn.Append("</select></div>");  
            }  
        }  
 
        return toReturn.ToString();  
    } 

It's not the best solution but for my purposes it works.
Tags
Window
Asked by
Kurt Boeckman
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Kurt Boeckman
Top achievements
Rank 1
Share this question
or