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

radprompt

6 Answers 328 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ayesha
Top achievements
Rank 1
Ayesha asked on 21 Aug 2009, 03:12 AM
Hi,

My scenario is this. I have 2 text boxes and 2 radcomboboxex which user needs to fill and then i've a button called save which "Prompts" the user for a name and saves it.

So, to do this, I did the foll in .ascx:

 

<button id="btnSave" style="width: 80px" onclick = "radprompt('Please enter a Search Name:',

 

promptCallBackFn, 330, 180); return false;"

 

>Save</button>

Now my question is
1) how do i grab the name that user entered in the prompt and use it in my .cs file.
how to make the name available in code behind file. pls do help me with code.

2) also, i need to make sure that user has selected atleast 1 radcombo box and  entered text in 1 textbox ctrl before prompting for a name. otherwise I need to alert the user telling "you don't have anything to save".
pls help me with code.
Thanks,
ZR

 

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Aug 2009, 08:21 AM
Hello Zaheka,

I tried the scenario on my end and here is the code.

CSS:
 
<style type="text/css"
.MyButton 
    displaynone
}     
</style> 

ASPX:
 
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"
</telerik:RadWindowManager> 
 
<telerik:RadTextBox ID="RadTextBox1" runat="server"
</telerik:RadTextBox> 
 
<telerik:RadTextBox ID="RadTextBox2" runat="server"
</telerik:RadTextBox> 
 
<telerik:RadComboBox ID="RadComboBox1" runat="server" AllowCustomText="true" EmptyMessage="Select a value"
    <Items> 
     . . . 
    </Items> 
</telerik:RadComboBox> 
<telerik:RadComboBox ID="RadComboBox2" AllowCustomText="true" EmptyMessage="Select a value" 
    runat="server"
    <Items> 
     . . . 
    </Items> 
</telerik:RadComboBox> 
 
<asp:Button ID="Button2" CssClass="MyButton" runat="server" Text="Button" OnClick="Button2_Click" /> 
<input id="Button1" type="button" value="Save" onclick="ShowPrompt();" /> 

JavaScript:
 
<script type="text/javascript"
function ShowPrompt() 
    var textbox1 = $find("<%=RadTextBox1.ClientID %>");   
    var textbox2 = $find("<%=RadTextBox2.ClientID %>");   
    var combo1 = $find("<%=RadComboBox1.ClientID %>");   
    var combo2 = $find("<%=RadComboBox2.ClientID %>");   
 
    if((textbox1.get_value() != "" || textbox2.get_value() != "") && (combo1.get_selectedIndex() != null || combo2.get_selectedIndex() != null) ) 
    {  
         radprompt('Please enter a Search Name:', promptCallBackFn, 330, 100, null,'Deep Thought''My Default search name');            
    } 
    else 
    {     
        radalert(" You don't have anything to save .."); 
    } 
function promptCallBackFn(arg) 
    // alert ("Prompt returned the following result: " + arg); 
    __doPostBack("Button2",arg); 
</script> 

C#:
 
protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument) 
   // base.RaisePostBackEvent(source, eventArgument); 
    if (source == Button2) 
    { 
        Response.Write(eventArgument.ToString()); // eventArgument represents the SearchName 
    } 
}  

Note: As far as I know the radprompt/radconfirm/radalert are work in client-side only and you need a postback to server if you want to pass the prompt/confirm value to server side. So I added and invisible button in page to invoke the postback for that and pass the search text as argument. And in the RaisePostBackEvent, check for the postback source control and get the passed value (search name) as eventArgument.

-Shinu.
0
Georgi Tunev
Telerik team
answered on 21 Aug 2009, 01:08 PM
Hello guys,

Here is some more information about the __doPostBack() function. If you are using RadAjax, you could also use ajaxRequest call.


Kind regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ayesha
Top achievements
Rank 1
answered on 25 Aug 2009, 04:15 AM
Hi Shinu,

I tried your foll. code. but I donot get "RaisePostBackEvent" intellisense in my c# code. Should i inherit any interface. I already my class is derived from another class. so, how do i inherit this too? pls explain with code.

I also don't need button2 to be visible in my code.

0
Shinu
Top achievements
Rank 2
answered on 25 Aug 2009, 07:47 AM
Hello Zaheka,

The " RaisePostBackEvent " method enables a server control to process an event raised when a form is posted to the server. Simply copy and paste the code in your application and see whether it is firing whenever a postback taking place.

CS:
 
protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument) 
    base.RaisePostBackEvent(source, eventArgument); 
    if (source == Button2) 
    { 
        Response.Write(eventArgument.ToString()); 
    } 

I am not sure about the visibility of button that you specified. You can hide the button by applying CSS as shown in previous post. Otherwise you could use an ajaxRequest request to the server from the client, as suggested by Georgi Tunev (if you are not using button and __doPostBack function).

Feel free to share the comments.
Shinu.
0
Abdul Kadar
Top achievements
Rank 1
answered on 10 Oct 2009, 01:08 PM
Hi Shinu,
How to call the radprompt & get the values from code-behind(vb).my Scenario is when the user clicks the Delete Link button, i need to open the radprompt .After getting the reason for deletion (codebehind).I need to store this value into  the database.As I am a beginner,Pls explain this by complete code.Thanks for you in advance.
Regards,
KADAR
0
Shinu
Top achievements
Rank 2
answered on 12 Oct 2009, 05:13 AM
Hello Abdul Kadar,

Refer the Knowledge Base which describes how to call radalert from code behind. Try the same logic for calling the RadPrompt.

And in the promptCallBackFn, invoke postback for an invisible button to get the result in the code behind as shown in previous reply. You could retrieve the argument (result) passed in RaisePostBackEvent event.

-Shinu.
Tags
Window
Asked by
Ayesha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Georgi Tunev
Telerik team
Ayesha
Top achievements
Rank 1
Abdul Kadar
Top achievements
Rank 1
Share this question
or