This really should be a very simple task to perform, but so far, we have only been able to find quite complex solutions based on "faiking postbacks" for it, that also seem hard to maintain over time (think Classic ASP). How do we catch Close events of a RadWindow in server side code so that we can execute some of our own code? This must be a very common scenario so I can't believe it not to be a simple built in solution for it? In case there really is not good solution for this, what is the least bad one to achieve the same thing?
8 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 09 Apr 2012, 08:13 AM
Hello Patrik,
You can access the AjaxManager on close of window and pass the CommandArgument from server side. Here is the sample code.
JS:
C#:
Thanks,
Shinu.
You can access the AjaxManager on close of window and pass the CommandArgument from server side. Here is the sample code.
JS:
function
OnClientClose(sender, args)
{
var
ajaxManager = $find(
"<%= RadAjaxManager1.ClientID %>"
).ajaxRequest(
"Close"
) ;
}
protected
void
RadAjaxManager1_AjaxRequest(
object
sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if
(e.Argument ==
"Close"
)
{
//you code
}
}
Thanks,
Shinu.
0
rdmptn
Top achievements
Rank 1
answered on 09 Apr 2012, 08:36 AM
Indeed, Shinu is right - the only way to catch a RadWindow's event on the server is to manually trigger the postback (full or partial). The control is entirely client-side and this is why it has no server events.
I also think you'll find this help article useful on using the RadAjaxManager and this one on using the regular __doPostBack(). This second one I took from this demo that shows a few neat tricks with it.
I also think you'll find this help article useful on using the RadAjaxManager and this one on using the regular __doPostBack(). This second one I took from this demo that shows a few neat tricks with it.
0

improwise
Top achievements
Rank 1
Iron
Iron
answered on 09 Apr 2012, 03:22 PM
Thanks for your feedback, much appreciated.
How would one go about to use this in best way with a RadAjaxManagerProxy since that does not expose the AjaxRequest method? Is this the way to go:
Would the "manager" intefer with the RadAjaxManagerProxy defined in the HTML markup? Also, would I need to define my own onRequestStart and onRequestEnd when using this code (which is from the RadAjaxManagerProxy documentation)? I'm assuming it would look for those event handlers in the javascript of the page? Do I even need to add define them?
As I said, all this trouble for just a Close-button...have us thinking of alternative solutions not using RadWindow at all (this might not be Teleriks fault really, but still very frustrating)
How would one go about to use this in best way with a RadAjaxManagerProxy since that does not expose the AjaxRequest method? Is this the way to go:
protected void Page_Load(object sender, EventArgs e) { RadAjaxManager manager = RadAjaxManager.GetCurrent(Page); manager.ClientEvents.OnRequestStart = "onRequestStart"; manager.ClientEvents.OnResponseEnd = "onResponseEnd"; manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest); } protected void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e) { //handle the manager AjaxRequest event here }
Would the "manager" intefer with the RadAjaxManagerProxy defined in the HTML markup? Also, would I need to define my own onRequestStart and onRequestEnd when using this code (which is from the RadAjaxManagerProxy documentation)? I'm assuming it would look for those event handlers in the javascript of the page? Do I even need to add define them?
As I said, all this trouble for just a Close-button...have us thinking of alternative solutions not using RadWindow at all (this might not be Teleriks fault really, but still very frustrating)
0
rdmptn
Top achievements
Rank 1
answered on 10 Apr 2012, 08:10 AM
There shouldn't be a problem. You only need to make sure you also add adequate AjaxSettings for this to work. If you do not need the client-side events of the manager you needn't declare them as well. You should also pass some custom argument and check for it in the server code so you can make sure you distinguish one ajax request from the other (e.g. "rwCloseRequest").
As I said before - you may find easier using __doPostBack() - place the controls you need to update in asp UpdatePanel, add a hidden button inside and in the OnClientClose handler call __doPostBack(<%=hiddenButton.UniqueID%>, ""); to initiate the request. Its far simpler. You can also add a hidden field to store some data and send it to the server. This will also allow you to attach an OnClick server handler to this button to execute some specific code. Essentially this is the same as the AjaxManager, but with one line of JS and no accessing of other controls from other pages.
As I said before - you may find easier using __doPostBack() - place the controls you need to update in asp UpdatePanel, add a hidden button inside and in the OnClientClose handler call __doPostBack(<%=hiddenButton.UniqueID%>, ""); to initiate the request. Its far simpler. You can also add a hidden field to store some data and send it to the server. This will also allow you to attach an OnClick server handler to this button to execute some specific code. Essentially this is the same as the AjaxManager, but with one line of JS and no accessing of other controls from other pages.
0

Stephen
Top achievements
Rank 1
answered on 30 Jan 2014, 03:05 PM
[quote]Shinu said:Hello Patrik,
You can access the AjaxManager on close of window and pass the CommandArgument from server side. Here is the sample code.
JS:
C#:
Thanks,
Shinu.[/quote]
Shinu,
Would you be so kind and write a small sample application that has a parent page that opens a radwindow that points to google.com. Then write the code on the back end that captures the closing of the radwindow and refreshes the parent page.
Thank you very much,
Stephen
You can access the AjaxManager on close of window and pass the CommandArgument from server side. Here is the sample code.
JS:
function
OnClientClose(sender, args)
{
var
ajaxManager = $find(
"<%= RadAjaxManager1.ClientID %>"
).ajaxRequest(
"Close"
) ;
}
protected
void
RadAjaxManager1_AjaxRequest(
object
sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if
(e.Argument ==
"Close"
)
{
//you code
}
}
Thanks,
Shinu.[/quote]
Shinu,
Would you be so kind and write a small sample application that has a parent page that opens a radwindow that points to google.com. Then write the code on the back end that captures the closing of the radwindow and refreshes the parent page.
Thank you very much,
Stephen
0

Shinu
Top achievements
Rank 2
answered on 31 Jan 2014, 10:06 AM
Hi Stephen,
Please have a look into the sample code snippet which works fine at my end.
ASPX:
JavaScript:
C#:
Thanks,
Shinu.
Please have a look into the sample code snippet which works fine at my end.
ASPX:
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
OnAjaxRequest
=
"RadAjaxManager1_AjaxRequest"
>
</
telerik:RadAjaxManager
>
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
NavigateUrl
=
"http://www.telerik.com"
OnClientClose
=
"OnClientClose"
>
</
telerik:RadWindow
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Open"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
JavaScript:
<script type=
"text/javascript"
>
function
OnClientClose(sender, args) {
var
ajaxManager = $find(
"<%= RadAjaxManager1.ClientID %>"
).ajaxRequest(
"Close"
);
}
</script>
C#:
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
RadWindow1.VisibleOnPageLoad =
true
;
}
protected
void
RadAjaxManager1_AjaxRequest(
object
sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if
(e.Argument ==
"Close"
)
{
//refresh the page
Response.Redirect(
"WindowCloseServer.aspx"
);
}
}
Thanks,
Shinu.
0

Stephen
Top achievements
Rank 1
answered on 04 Feb 2014, 07:32 PM
<%@ Page Title="Pikepass Administration Management:CAO Incompletes" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CAOIncompletes.aspx.cs" Inherits="PAMRewrite.CAOIncompletes" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="PAMStats.ascx" TagName="PAMStats" TagPrefix="uc1" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"HeadContent"
runat
=
"server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"MainContent"
runat
=
"server"
>
<
telerik:RadCodeBlock
runat
=
"server"
ID
=
"rdbScripts"
>
<
script
type
=
"text/javascript"
>
function openRadWin(URL) {
var width = 1000;
var height = 800;
var left = 600;
var top = 100;
radopen(URL, width, height, left, top);
}
function OnClientClose(sender, args) {
var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Close");
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxPanel
runat
=
"server"
ID
=
"rapConfiguration"
LoadingPanelID
=
"ralpConfiguration"
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
EnableShadow
=
"true"
Top
=
"100"
Left
=
"600"
Height
=
"800"
Width
=
"1000"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
ShowContentDuringLoad
=
"false"
Style
=
"z-index: 8000"
Title
=
"CAO"
Behaviors
=
"Default"
OnClientClose
=
"OnClientClose"
>
</
telerik:RadWindow
>
</
Windows
>
</
telerik:RadWindowManager
>
</
telerik:RadAjaxPanel
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
OnAjaxRequest
=
"RadAjaxManager1_AjaxRequest"
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadToolTipManager
ID
=
"RadToolTipManager1"
OffsetY
=
"-1"
HideEvent
=
"Default"
AutoCloseDelay
=
"7000"
Width
=
"325"
Height
=
"275"
runat
=
"server"
OnAjaxUpdate
=
"OnAjaxUpdate"
RelativeTo
=
"Element"
Position
=
"MiddleRight"
>
</
telerik:RadToolTipManager
>
<
div
class
=
"well"
>
<
h3
runat
=
"server"
id
=
"h1Header"
>CAO Incompletes</
h3
>
<
hr
/>
<
asp:UpdatePanel
runat
=
"server"
ID
=
"updMainPanel"
UpdateMode
=
"Conditional"
>
<
ContentTemplate
>
<
uc1:PAMStats
ID
=
"PAMStats1"
runat
=
"server"
Visible
=
"false"
/>
<
br
/>
<
p
>The Go To Account button will allow you to finish for the customer once the account is identified.</
p
>
<
asp:UpdatePanel
runat
=
"server"
ID
=
"upIncompleteSearch"
UpdateMode
=
"Conditional"
>
<
ContentTemplate
>
<
div
class
=
"control-group"
>
<
asp:Panel
ID
=
"pnlLogin"
runat
=
"server"
class
=
"search"
>
<
div
class
=
"control-group"
>
<
div
class
=
"form-inline"
>
<
asp:Label
runat
=
"server"
ID
=
"lblLastName"
Width
=
"200px"
Text
=
"Last Name:"
></
asp:Label
>
<
telerik:RadTextBox
ID
=
"tbLastName"
runat
=
"server"
>
</
telerik:RadTextBox
>
<
asp:RequiredFieldValidator
ID
=
"rffLastName"
runat
=
"server"
ControlToValidate
=
"tbLastName"
ErrorMessage
=
"Last Name is required."
ValidationGroup
=
"CAOIncompSearch"
Display
=
"Dynamic"
SetFocusOnError
=
"true"
><
img
class
=
"required"
src
=
"img/required.png"
alt
=
"*"
/></
asp:RequiredFieldValidator
>
</
div
>
</
div
>
<
div
class
=
"control-group"
>
<
div
class
=
"form-inline"
>
<
asp:Label
runat
=
"server"
ID
=
"lblDLNumber"
Width
=
"200px"
Text
=
"Driver's License (Last 5 Digits):"
></
asp:Label
>
<
telerik:RadTextBox
ID
=
"tbDLNumber"
runat
=
"server"
>
</
telerik:RadTextBox
>
<
asp:RequiredFieldValidator
ID
=
"rfvDLNumber"
runat
=
"server"
ControlToValidate
=
"tbDLNumber"
ErrorMessage
=
"Driver's License Number is required."
ValidationGroup
=
"CAOIncompSearch"
Display
=
"Dynamic"
SetFocusOnError
=
"true"
><
img
class
=
"required"
src
=
"img/required.png"
alt
=
"*"
/></
asp:RequiredFieldValidator
>
</
div
>
</
div
>
<
div
class
=
"control-group"
>
<
div
class
=
"form-inline"
>
<
asp:Label
runat
=
"server"
ID
=
"lblZIPCode"
Width
=
"200px"
Text
=
"ZIP Code:"
></
asp:Label
>
<
telerik:RadTextBox
ID
=
"tbZIPCode"
runat
=
"server"
>
</
telerik:RadTextBox
>
<
asp:RequiredFieldValidator
ID
=
"rfvZIPCode"
runat
=
"server"
ControlToValidate
=
"tbZIPCode"
ErrorMessage
=
"ZIP Code is required."
ValidationGroup
=
"CAOIncompSearch"
Display
=
"Dynamic"
SetFocusOnError
=
"true"
><
img
class
=
"required"
src
=
"img/required.png"
alt
=
"*"
/></
asp:RequiredFieldValidator
>
</
div
>
</
div
>
<
div
class
=
"control-group"
>
<
div
class
=
"form-inline"
>
<
asp:Button
ID
=
"imgCAOIncompSearch"
runat
=
"server"
CssClass
=
"btn"
ValidationGroup
=
"CAOIncompSearch"
OnClick
=
"btnCAOIncompSearch_Click"
Text
=
"Search"
/>
</
div
>
</
div
>
<
div
class
=
"control-group"
>
<
div
class
=
"form-inline"
>
<
asp:ValidationSummary
ID
=
"vsCAOIncompSearch"
runat
=
"server"
CssClass
=
"Validation"
DisplayMode
=
"BulletList"
ValidationGroup
=
"CAOIncompSearch"
ForeColor
=
"#AF0B0B"
/>
</
div
>
</
div
>
</
asp:Panel
>
</
div
>
</
ContentTemplate
>
</
asp:UpdatePanel
>
<
asp:UpdatePanel
runat
=
"server"
ID
=
"upIncompleteList"
UpdateMode
=
"Conditional"
>
<
ContentTemplate
>
<
asp:Panel
ID
=
"pnlIncompleteListGrid"
runat
=
"server"
GroupingText
=
"CAO Queue List"
>
<
telerik:RadGrid
ID
=
"gridIncompleteList"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"True"
GridLines
=
"None"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
Skin
=
"Default"
OnItemDataBound
=
"gridIncompleteList_ItemDataBound"
OnItemCommand
=
"gridIncompleteList_ItemCommand"
>
<
SortingSettings
EnableSkinSortStyles
=
"false"
></
SortingSettings
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
DataKeyNames
=
"Profile_ID"
NoMasterRecordsText
=
"There are no CAO Incomplete records."
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
AlwaysVisible
=
"True"
></
PagerStyle
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"PROFILE_ID"
Display
=
"false"
FilterControlAltText
=
"Filter profileid column"
HeaderText
=
"Profile ID"
UniqueName
=
"customername"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CUSTOMERNAME"
FilterControlAltText
=
"Filter customername column"
HeaderText
=
"Customer Name"
UniqueName
=
"CUSTOMERNAME"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"EMAIL_ADDRESS"
AllowFiltering
=
"false"
FilterControlAltText
=
"Filter email_address column"
HeaderText
=
"Email address"
UniqueName
=
"EMAIL_ADDRESS"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DRIVERS_LICENSE_NO"
FilterControlAltText
=
"Filter drivers_license_no column"
HeaderText
=
"DL #"
UniqueName
=
"DRIVERS_LICENSE_NO"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Details"
SortExpression
=
"Details"
>
<
ItemTemplate
>
<
asp:HyperLink
ID
=
"targetControl"
runat
=
"server"
NavigateUrl
=
"#"
Text
=
"Details"
></
asp:HyperLink
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
HeaderText
=
"Details"
UniqueName
=
"DetailsColumn"
>
<
ItemTemplate
>
<
asp:LinkButton
runat
=
"server"
ID
=
"lnkGotoAccount"
Text
=
"Go To Account"
CommandName
=
"GoToAccount"
></
asp:LinkButton
>
|
<
asp:LinkButton
runat
=
"server"
ID
=
"lnkCheckIn"
Text
=
"Check In"
CommandName
=
"CheckIn"
Visible
=
"false"
></
asp:LinkButton
>
<
asp:Label
ID
=
"lblProfileId"
runat
=
"server"
Visible
=
"false"
Text='<%#Eval("PROFILE_ID") %>' />
<
asp:Label
ID
=
"lblBillingZip"
runat
=
"server"
Visible
=
"false"
Text='<%#Eval("BILLING_ZIP") %>' />
<
asp:Label
ID
=
"lblSignupStep"
runat
=
"server"
Visible
=
"false"
Text='<%#Eval("ACCOUNT_STATUS_DESC") %>' />
<
asp:Label
ID
=
"lblPreAccountNo"
runat
=
"server"
Visible
=
"false"
Text='<%#Eval("PRE_ACCOUNT_NO") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"USERNAME"
FilterControlAltText
=
"FilterUserName"
HeaderText
=
"Checked Out By"
UniqueName
=
"USERNAME"
>
<
HeaderStyle
Width
=
"100px"
VerticalAlign
=
"Middle"
HorizontalAlign
=
"Center"
/>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
EditItemStyle
BorderWidth
=
"5px"
/>
</
telerik:RadGrid
>
</
asp:Panel
>
</
ContentTemplate
>
</
asp:UpdatePanel
>
</
ContentTemplate
>
</
asp:UpdatePanel
>
</
div
>
</
asp:Content
>
using
System;
using
System.Data;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
PAMRewrite.PAMBiz;
using
Telerik.Web.UI;
namespace
PAMRewrite
{
public
partial
class
CAOIncompletes : System.Web.UI.Page
{
private
const
string
CAO_INCOMP_SEARCH =
"CAOIncompSearch"
;
protected
void
OnAjaxUpdate(
object
sender, ToolTipUpdateEventArgs args)
{
this
.UpdateToolTip(args.Value, args.UpdatePanel);
}
private
void
UpdateToolTip(
string
elementID, UpdatePanel panel)
{
Control ctrl = Page.LoadControl(
"HoverDetail.ascx"
);
ctrl.ID =
"ucCustomerDetails1"
;
panel.ContentTemplateContainer.Controls.Add(ctrl);
HoverDetail details = (HoverDetail)ctrl;
details.Profile_ID = Convert.ToInt32(elementID);
}
protected
void
RadAjaxManager1_AjaxRequest(
object
sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if
(e.Argument ==
"Close"
)
{
Response.Redirect(
"CAOIncompletes.aspx"
);
}
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
//string scriptstring = "Sys.Application.add_load(showDialogInitially);";
//ScriptManager.RegisterStartupScript(Page, Page.GetType(), "radalert", scriptstring, true);
string
CheckAuth = (
string
)Session[
"Authenticated"
];
if
((CheckAuth ==
null
) || (CheckAuth ==
"FALSE"
))
{
Response.Redirect(
"Default.aspx"
,
false
);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
else
{
upIncompleteSearch.Visible =
false
;
// Make sure that UserType is authenticated
if
((Convert.ToInt32(Session[
"UserType"
]) == Convert.ToInt32(cEnums.eUserType.EXTADMIN)) ||
(Convert.ToInt32(Session[
"UserType"
]) == Convert.ToInt32(cEnums.eUserType.EXTUSER)))
{
Response.Redirect(
"MainMenu.aspx"
,
false
);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
Session[
"Error"
] =
"FALSE"
;
h1Header.InnerText =
"CAO Incompletes List"
;
if
(Session[
"From"
] !=
null
)
{
if
(Session[
"From"
].ToString() == CAO_INCOMP_SEARCH)
{
h1Header.InnerText =
"CAO Incompletes Search"
;
upIncompleteList.Visible =
false
;
upIncompleteSearch.Visible =
true
;
}
}
if
(!IsPostBack)
{
Session[
"isCAOSearch"
] =
"false"
;
if
(Session[
"From"
] !=
null
)
{
if
(Session[
"From"
].ToString() == CAO_INCOMP_SEARCH)
{
SetupPageLoadControls();
}
else
{
FillIncompleteListGrid();
}
}
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(
false
);
}
if
((Int32)Session[
"UserType"
] == Convert.ToInt32(cEnums.eUserType.SUPERADMIN) || (Int32)Session[
"UserType"
] == Convert.ToInt32(cEnums.eUserType.INTADMIN))
{
if
(Session[
"From"
] !=
null
)
{
if
(Session[
"From"
].ToString() != CAO_INCOMP_SEARCH)
{
PAMStats1.Visible =
true
;
RadTabStrip tsStats = (RadTabStrip)PAMStats1.FindControl(
"RadTabstrip1"
);
RadTab tab1 = tsStats.Tabs.FindTabByText(
"CAO Statistics"
);
tab1.Selected =
true
;
}
}
}
}
}
protected
void
gridIncompleteList_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName ==
"GoToAccount"
)
{
GridDataItem item = e.Item
as
GridDataItem;
string
domainURL = Common.GetConfigurationSetting(
"PAMDomainUrl"
);
string
caoUrl = domainURL.ToString() + Common.GetConfigurationSetting(
"CAOLoginURL"
);
string
emailAddress = item[
"EMAIL_ADDRESS"
].Text;
string
DLNumber = item[
"DRIVERS_LICENSE_NO"
].Text;
Label lblBillingZip = (Label)item.FindControl(
"lblBillingZip"
);
string
billingZip = lblBillingZip.Text.ToString();
string
url = caoUrl +
"?email="
+ emailAddress +
"&dl="
+ DLNumber +
"&ac="
+ billingZip;
string
scriptstring =
"openRadWin('"
+ url +
"');"
;
Random random =
new
Random();
int
randomNumber = random.Next(0, 100);
// In order for this functionality to work you have to follow these steps. Click on the "Go To Account" link.
// You will see a window open and it should populate the username and other information automatically and log you
// into CAO. When you are finished working in CAO you MUST log out of CAO. This will make it so other clicks on
// "Go To Account" will autopopulate the login fields. Remember to log out of CAO!!!
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"radScript"
+ randomNumber, scriptstring,
true
);
Label lblProfileId = (Label)item.FindControl(
"lblProfileId"
);
Int32 profileID = Convert.ToInt32(lblProfileId.Text.ToString());
Int32 userid = Convert.ToInt32(Session[
"UserId"
].ToString());
try
{
KioskInformation kioskInfo =
new
KioskInformation();
kioskInfo.UpdateCheckOutStatus(profileID, userid);
Label lblSignup = (Label)item.FindControl(
"lblSignupStep"
);
string
status = lblSignup.Text;
if
(status ==
"PAYMENT APPLIED TO ACCOUNT"
)
{
Label lblPreAcctNo = (Label)item.FindControl(
"lblPreAccountNo"
);
Session[
"From"
] =
"Kiosk"
;
//HARD_CODED - we are coming from Kiosk
Session[
"PreAccountNo"
] = lblPreAcctNo.Text;
Session[
"ProfileId"
] = profileID;
Response.Redirect(
"CAOAssignTags.aspx"
,
false
);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
FillIncompleteListGrid();
HttpResponse.RemoveOutputCacheItem(
"/KioskList.aspx"
);
}
catch
(Exception ex)
{
//If ReturnCode Return -990 means Needs to Refresh screen some one check out
if
(!(ex.Message.Contains(
"-990"
) || ex.Message.Contains(
"-991"
)))
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"ss"
,
"<script>alert('The tag request is currently checked out to another user.');</script>"
,
false
);
}
else
{
ErrorLogging logging =
new
ErrorLogging();
logging.callingPage = Request.Url.ToString();
logging.callingMethod = System.Reflection.MethodBase.GetCurrentMethod().Name;
ErrorLogging.LogError(ex, logging);
}
}
}
else
if
(e.CommandName ==
"CheckIn"
)
{
GridDataItem item = e.Item
as
GridDataItem;
Label lblProfileId = (Label)item.FindControl(
"lblProfileId"
);
Int32 profileID = Convert.ToInt32(lblProfileId.Text.ToString());
CAOInformation.UpdateCheckInStatus(profileID);
FillIncompleteListGrid();
}
else
if
(e.CommandName ==
"Sort"
|| e.CommandName ==
"Page"
)
{
RadToolTipManager1.TargetControls.Clear();
}
}
protected
void
gridIncompleteList_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
//to access a row
{
string
loginUser = Session[
"User"
].ToString();
LinkButton lnkCheckIn = (LinkButton)e.Item.FindControl(
"lnkCheckIn"
);
DataRowView row = (DataRowView)e.Item.DataItem;
string
profileID = row[
"PROFILE_ID"
].ToString();
if
(!
string
.IsNullOrEmpty(row[
"USERNAME"
].ToString()))
{
LinkButton lnkGotoAccount = (LinkButton)e.Item.FindControl(
"lnkGotoAccount"
);
if
(loginUser.ToUpper() == (row[
"USERNAME"
].ToString().ToUpper()))
{
lnkCheckIn.Visible =
true
;
}
else
{
lnkGotoAccount.Visible =
false
;
}
//If Current User Type is Super Admin then Check in Button is Visiable.
if
(Convert.ToInt32(Session[
"UserType"
]) == Convert.ToInt32(cEnums.eUserType.SUPERADMIN) || Convert.ToInt32(Session[
"UserType"
]) == Convert.ToInt32(cEnums.eUserType.INTADMIN))
{
lnkCheckIn.Visible =
true
;
}
}
if
(e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
{
Control target = e.Item.FindControl(
"targetControl"
);
if
(!Object.Equals(target,
null
))
{
if
(!Object.Equals(
this
.RadToolTipManager1,
null
))
{
//Add the button (target) id to the tooltip manager
this
.RadToolTipManager1.TargetControls.Add(target.ClientID, (e.Item
as
GridDataItem).GetDataKeyValue(
"Profile_ID"
).ToString(),
true
);
}
}
}
}
}
private
void
FillIncompleteListGrid()
{
CAOInformation caoInfo =
new
CAOInformation();
string
lastName = String.Empty;
string
driverLicenceNo = String.Empty;
string
zipCode = String.Empty;
using
(DataSet dsCAOIncomplete = caoInfo.GetCAOIncompleteList(lastName, driverLicenceNo, zipCode))
{
dsCAOIncomplete.Tables[0].DefaultView.Sort =
"CUSTOMERNAME ASC"
;
gridIncompleteList.DataSource = dsCAOIncomplete.Tables[0].DefaultView;
gridIncompleteList.DataBind();
DataView dViewCAOIncomp = dsCAOIncomplete.Tables[0].DefaultView;
Session.Add(
"dViewCAOIncompList"
, dViewCAOIncomp);
}
}
private
void
SetupPageLoadControls()
{
ClearSearchValues();
Page.Form.DefaultFocus = tbLastName.UniqueID;
Page.Form.DefaultButton = imgCAOIncompSearch.UniqueID;
tbLastName.Focus();
}
private
void
ClearSearchValues()
{
tbLastName.Text = String.Empty;
tbDLNumber.Text = String.Empty;
tbZIPCode.Text = String.Empty;
}
protected
void
btnCAOIncompSearch_Click(
object
sender, EventArgs e)
{
Session[
"isCAOSearch"
] =
"true"
;
CAOInformation caoInfo =
new
CAOInformation();
string
lastName = tbLastName.Text;
string
driverLicenceNo = tbDLNumber.Text;
string
zipCode = tbZIPCode.Text;
using
(DataSet dsCAOSearchIncompList = caoInfo.GetCAOIncompleteList(lastName, driverLicenceNo, zipCode))
{
if
(dsCAOSearchIncompList.Tables[0].Rows.Count > 0)
{
upIncompleteSearch.Visible =
true
;
upIncompleteList.Visible =
true
;
dsCAOSearchIncompList.Tables[0].DefaultView.Sort =
"CUSTOMERNAME ASC"
;
gridIncompleteList.DataSource = dsCAOSearchIncompList.Tables[0].DefaultView;
gridIncompleteList.DataBind();
DataView dViewCAOIncomp = dsCAOSearchIncompList.Tables[0].DefaultView;
Session.Add(
"dViewCAOIncompList"
, dViewCAOIncomp);
if
((Int32)Session[
"UserType"
] == Convert.ToInt32(cEnums.eUserType.SUPERADMIN) || (Int32)Session[
"UserType"
] == Convert.ToInt32(cEnums.eUserType.INTADMIN))
{
PAMStats1.Visible =
true
;
RadTabStrip tsStats = (RadTabStrip)PAMStats1.FindControl(
"RadTabstrip1"
);
RadTab tab1 = tsStats.Tabs.FindTabByText(
"CAO Statistics"
);
tab1.Selected =
true
;
}
}
else
{
CustomValidator cusval =
new
CustomValidator();
cusval.IsValid =
false
;
cusval.ErrorMessage =
"Account not found. Please try again."
;
cusval.ValidationGroup =
"CAOIncompSearch"
;
this
.Page.Validators.Add(cusval);
}
}
}
}
}
Thanks Shinu,
However, I still am unable to capture the close of the RadWindow. The method RadAjaxManager1_AjaxRequest is never hit. I am attaching my files so you can take a look and tell me why this is happening.
0
Hi,
I have just answered your support ticket with the same question and here is my answer for anyone else that may have a similar issue:
The problem is that the wrong RadWIndow is opened and it does not have the OnClientClose handler attached. This article explains how to open RadWIndows: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html. You will see that the second parameter to radopen() is the RadWindow name.
I can suggest three possible ways to get this done:
- open the correct RadWindow:
- OR, attach a handler dynamically:
- OR, simply redirect the page with JavaScript to avoid an unnecessary postback
Regards,
Marin Bratanov
Telerik
I have just answered your support ticket with the same question and here is my answer for anyone else that may have a similar issue:
The problem is that the wrong RadWIndow is opened and it does not have the OnClientClose handler attached. This article explains how to open RadWIndows: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html. You will see that the second parameter to radopen() is the RadWindow name.
I can suggest three possible ways to get this done:
- open the correct RadWindow:
function
openRadWin(URL)
{
var
width = 1000;
var
height = 800;
var
left = 600;
var
top = 100;
radopen(URL,
"RadWindow1"
,
width, height, left, top);
}
- OR, attach a handler dynamically:
var
wnd = radopen(URL,
null
, width, height, left, top);
wnd.add_close(OnClientClose);
- OR, simply redirect the page with JavaScript to avoid an unnecessary postback
function
OnClientClose(sender, args)
{
window.location.href =
"CAOIncompletes.aspx"
;
}
Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.