6 Answers, 1 is accepted
Indeed, this is intended behavior. The callback function passes true or false as an argument depending on what the user has clicked. For more information you can check the example in our online demos:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Window/Examples/BrowserDialogBoxes/DefaultCS.aspx
Regards,
Georgi Tunev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Indeed, this is an omission from our side - when cancel is clicked, the dialog should return null.
Thank you for bringing this problem to our attention - we will fix it for the Service Pack and for now you can modfy the prompttemplate and return null as an argument:
<div> |
<a id="OKbtn_{0}" onclick="$find('{0}').callBack(this.parentNode.parentNode.getElementsByTagName('input')[0].value);" |
class="radwindowbutton" href="javascript:void(0);" ><span class="outerspan"><span class="innerspan">##LOC[OK]##</span></span></a> |
<a onclick="$find('{0}').callBack(null);" class="radwindowbutton" href="javascript:void(0);"><span class="outerspan"><span class="innerspan">##LOC[Cancel]##</span></span></a> |
</div> |
For convenience I attached a sample page that shows this approach. I also updated your points for bringing this problem to our attention.
All the best,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
.aspx page -
...html content...
<
asp:ImageButton ImageAlign="Bottom" runat="server" ID="AddNewImg" OnClientClick="promptFn(); return false;" ImageUrl="~/images/add_user.png" Height="24" Width="24" />
<script type="text/javascript">
function openRadWin()
{
radopen(
"","RadUploadWindow");
}
function promptFn()
{
radprompt(
"<p>Enter new client name:</p>", promptCallBackFn, 330, 160, null, "Client Entry");
return false;
}
function promptCallBackFn(arg)
{
PageMethods.AddNewClient(arg, ShowResult);
}
function ShowResult(arg)
{
radalert (
"Result: <h3 style='color: #ff0000;'>" + arg + "</h3>",null,null, "Results");
}
</script>
ok so at this poing we have an image button that has a clientside onclick event to call "promptFn()" which uses the following page method from code-behind:
[
WebMethod]
public static string AddNewClient(string name)
{
if (name == null) return "Action Canceled"; //THIS IS KEY!! WHEN CANCEL IS CLICKED THE RETURN ARG IS NULL SO THE STRING PASSED IS NULL
if (name.Length > 0)
{
if (!Directory.Exists(mypath + "/Clients/" + name)) //SINCE YOU CANT USE SERVER.MAPPATH I DECLARED A STATIC VAR AND
{ //DEFINED IT IN THE PAGE_LOAD EVENT
Directory.CreateDirectory(mypath + "/Clients/" + name);
if (Directory.Exists(mypath + "/Clients/" + name))
{
return "Success"; }
else{return "Error: Duplicate entry."; }
}
else{return "Error: Already Exists.";}
}
else{return "Error: No name entered.";}
}
The result of this is the following:
User clicks on "add client image" and you get radprompt "enter new client name" now...
1) user clicks ok with text in box
a) code behind gets the client name string as an argument and processes because it has a length > 0
b) returns string depending on if there is a duplicate or not
c) Result shown by radalert box
2)User clicks ok with no text
a) code behind gets blank string as argument
b) returns a "NO NAME ENTERED" string
c) result shown by radalert box
3) User clicks cancel
a) a null string is passed to code behind
b) returns a string to say it was canceled
c) radalert shows "CANCELED ACTION"
**DONT FORGET TO USE:
<
asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"> <-----YOU MUST HAVE THIS SET TO TRUE
</asp:ScriptManager>
Cheers,
Kiel