I have a decent workaround i wanted to share. I am using a radprompt to collect a string from a user then processing it from code behind when "OK" is selected. The way i handled the cancel issues to deal with the argument being null. My code is below with brief explanations. Hope this helps someone.
.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