13 Answers, 1 is accepted
I am not quite sure about the way you have designed your aspx. The following KB article discusses calling radalert from code behind.
Calling radalert from codebehind (all versions of RadWindow)
C#:
RadWindowManager1.RadAlert(
"RadAlert is called from the server"
,
"Server RadAlert"
,
"alertCallBackFn"
);
Another approach is to implement RadAlert using direct method. The predefined dialogs (radalert, radconfirm and radprompt) can be now called by using the new server methods RadAlert, RadConfirm and RadPrompt of the RadWindowManager.
Window / Alert, Prompt, Confirm.
Thanks,
Shinu.
RadWindowManager1
that don't have radalert or RadConfirm.
doesn't contain definition for RadConfirm and no extension method RadConfirm accepting first argument of type using Telerik.Web.UI.RadWindowManager1; could be found (are you missing a using directer or an assembly reference)
Thanks ,
Mohamed .
This feature is available from Q1 2011 (version 2011.1.315) release. I suggest you to upgrade to the latest version.
Thanks,
Shinu.
how can i rectify it
If you have any idea
Thanks,
Mohamed.
Hi Mohamed,
I am not sure what your scenario is, but it looks like you want to show an alert from the server-side. As the previous post suggested you can:
- use the RadWindowManager's methods, but for that you would first need to have a RadWindowManager on the page (or on the master page if the scenario is more complex). These methods are available since Q1 2011
- If you are using an earlier version I would suggest that you upgrade to the latest release. If that is not possible please refer to the previously suggested blog post on executing a JavaScript function from the server-side.
- If you are using AJAX you can use the ScriptManager's RegisterStartupScript() method.
If you are still experiencing difficulties please open a support ticket and send us detailed information on the issue you are having along with detailed reproduction steps and we will do our best to help.
All the best,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
i'm already see those examples .
how i post the this error to support ticket
i'm use this version v4.0.30319
i'm not use this alert button click ,
how i'm going to use this alert on "RadGrid1_ItemCommand"
Thanks,
Mohamed
Hello Mohamed,
You need to capture the Item Command event and use one of the approaches recommended below.
For your convenience I created and attached a simple page that uses an image button click and a regular button click to initiate the ItemCommand event, but you can use your own custom logic for that. In the code-behind I chose to inject a JavaScript function that calls the RadAlert, but you can use any other method, too. Please note that you need a RadWindowManager on the page to be able to call a RadAlert, RadConfirm or RadPrompt.
All the best,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
how i get the value from radconfirm message yes or no
if yes i perform some operation.
how return the valur form java script
ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "radconfirm('This Asset Make Use Ticket, Are Sure Delete This Asset?',confirmCallBackFn, 330, 100, null,'Send Message?');", true);
js:
function confirmCallBackFn(arg) {
debugger;
if (arg == true) {
alert("If True");
return true;
}
else {
alert("Else");
return false;
}
}
Thanks,
Mohamed.
Hi Mohamed,
Your code seems correct to me - the value returned from the confirm dialog box is contained in the argument you pass to the callback function.
I tested it in the previous page and it is working correctly on my end. You can find attached my test page with the new modification applied. Please note that you need to make sure that the controls are loaded before trying to use them, hence the usage of the Sys.Application.Load event.
If that does not help you please open a formal support ticket and send us a sample project that displays your issue along with detailed explanations of the desired effect and the difficulties you are having with our controls. At the current state of affairs I am mostly guessing what your scenario and needs are and in order to be able to provide a more to the point answer I will need your code and a more detailed explanation of your issues.
Greetings,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
i got alert message,
how i get the alert message value in sever side ,
i check like that for example
if (arg == true)
{
string updateQuery = "UPDATE [Assets] SET Asset_Inactive=1 WHERE [AssetID] ='" + AssetID + "'";
sqlcmd.CommandText = updateQuery;
sqlcmd.Connection = SqlConn;
sqlcmd.ExecuteNonQuery();
}
reply as soon as possible.
Thanks,
Mohamed.
One suggestion is to use RadAjaxManager and make the ajaxRequest and pass the argument.
Javascript:
function
confirmCallBackFn(arg)
{
if
(arg ==
true
)
{
alert(
"confirm returned the following value: "
+ arg);
var
ajxmgr = $find(
"<%=RadAjaxManager1.ClientID%>"
);
//AjaxManager1 is the AjaxManager on page
ajxmgr.ajaxRequest(arg);
}
. . . . . . .
}
C#:
private
void
RadAjaxManager1_AjaxRequest(
object
sender, AjaxRequestEventArgs e)
{
//code to handle the generic AJAX request
}
Also take a look at the following help article.
client-side API
Thanks,
Princy.
i work this function radgrid_itemcommand
like that
js:
function confirmCallBackFn(arg) {
debugger;
var sample
if (arg == true) {
alert("If True");
}
else {
alert("Else");
}
}
C#
if (e.CommandName == RadGrid.DeleteCommandName)
{
GridDataItem item = (GridDataItem)e.Item;
string AssetID = item["AssetID"].Text;
assignAssets(LoadAssets(AssetID));
try
{
string selectQuery = "select * from Tickets a , Assets b where a.Ticket_AssetID=b.AssetID and a.Ticket_AssetID = " + AssetID;
sqladp.SelectCommand = new SqlCommand(selectQuery, SqlConn);
sqladp.Fill(dt1);
int i = dt1.Rows.Count;
dt1 = null;
if (i > 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "radconfirm('This Asset Make Use Ticket, Are Sure Delete This Asset?',confirmCallBackFn, 330, 100, null,'Send Message?');", true);
""""""""""" here i want to check if the script's true this going to update,
""""""""""" false not needed
//string updateQuery = "UPDATE [Assets] SET Asset_Inactive=1 WHERE [AssetID] ='" + AssetID + "'";
//sqlcmd.CommandText = updateQuery;
//sqlcmd.Connection = SqlConn;
//sqlcmd.ExecuteNonQuery();
}
else
{
SqlConn.Open();
string deleteQuery1 = "DELETE FROM [Asset_Lease] WHERE [LeaseID] ='" + leaseid + "'";
sqlcmd.CommandText = deleteQuery1;
sqlcmd.Connection = SqlConn;
sqlcmd.ExecuteNonQuery();
string deleteQuery2 = "DELETE FROM [Asset_Service_Contracts] WHERE [Contract_AssetID] ='" + AssetID + "'";
sqlcmd.CommandText = deleteQuery2;
sqlcmd.Connection = SqlConn;
sqlcmd.ExecuteNonQuery();
string deleteQuery = "DELETE FROM [Assets] WHERE [AssetID] ='" + AssetID + "'";
sqlcmd.CommandText = deleteQuery;
sqlcmd.Connection = SqlConn;
sqlcmd.ExecuteNonQuery();
SqlConn.Close();
}
selectQuery = "SELECT a.AssetID,a.AssetName,a.SerialNumber,a.Asset_UserID,b.ppl_Name,a.Asset_Inactive FROM [Assets] a , People b " +
"where a.Asset_UserID=b.PeopleID order by AssetName asc";
sqladp.SelectCommand = new SqlCommand(selectQuery, SqlConn);
sqladp.Fill(dt2);
RadGrid1.DataSource = dt2;
}
catch (Exception ex)
{
RadGrid1.Controls.Add(new LiteralControl("Unable to delete Id. Reason: " + ex.Message));
e.Canceled = true;
}
}
Thanks,
Mohamed.
Hello Mohamed,
The RadConfirm is a client-side object and thus uses JavaScript. This means that you cannot block the execution thread on the server while waiting for the response from the client.
What I would suggest is to split this method in two
- inject the client-side script and get the result from the RadConfirm on the client side
- depending on that result call a hidden button's server-side click event where you update the database (the second part of the current method)
You can pass the necessary values in hidden fields on the page, in the viewstate or as global variables or properties in the code-behind's class, this decision is up to the developer and depends on your custom scenario.
Here is a small example how to execute a server-side function from JavaScript:
<
input
type
=
"button"
id
=
"btnHidden"
style
=
"display:none"
runat
=
"server"
onserverclick
=
"serverside_handler"
/>
<
asp:Button
ID
=
"Button1"
Text
=
"call method"
runat
=
"server"
OnClientClick
=
"callMethod(); return false;"
/>
<
asp:Label
ID
=
"Label1"
Text
=
""
runat
=
"server"
/>
function
callMethod()
{
document.getElementById(
"<%=btnHidden.ClientID %>"
).click();
}
protected
void
serverside_handler(
object
sender, EventArgs e)
{
Label1.Text =
"from code-behind"
;
}
Greetings,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.