INT converted to boolean updateable in a checkbox - c#

I have been programming for many years, about 10 in an older version of .NET, as a result I'm new to LINQ, UpdatePanels and Ajax and their way of doing things.
The following code works correctly.
The database field is defined as:
rptPriority INT NOT NULL DEFAULT(0)
A much simplified page stub which works is:
<asp:UpdatePanel ID="upReport" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<fieldset>
<asp:DetailsView ID="dvReport" runat="server" DataSourceID="ldsReport" CssClass="reset"
AutoGenerateRows="False" DefaultMode="Edit" Width="100%">
<Fields>
<asp:TemplateField>
<ItemTemplate>
<asp:DynamicControl ID="Priority" runat="server" DataField="rptPriority" Mode="Edit" CssClass="general" />
etc
What I need to do is change that Dynamic Control as a textbox to a checkbox which is updatable and driven by the same data. The following gives the correct data but doesn't update.
Were I doing this using straight SQL or PROCEDURES, this would not be a big problem. (also not an option)
<asp:CheckBox ID="Priority" runat="server" Checked='<%# Convert.ToBoolean(Eval("rptPriority")) %>' />
I changed "Eval" to "Bind" and got the "ERROR CS0103: The name 'Bind' does not exist in the current context"
I suspect that the "Convert.ToBoolean" is part of the problem.
There are many pages which I've perused trying to get the info I need. Among them How to add checkbox to datagrid in vb.net , Html.CheckBox returns false if disabled, even if seleced and Checkbox server/client events , How do you know to use Container.DataItem when data binding in ASP.NET? Is there a reference? , The databind bind() function belongs to which class? not to mention about 50 more outside of stack overflow which got me to where I am now.
Edit
As per Rob's suggestion, I added the following, but couldn't get / find any way to use "DetailsViewUpdateEventArgs".
protected void dvReport_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
DetailsView dv = sender as DetailsView;
CheckBox ctlPriority = dv.FindControl("Priority") as CheckBox;
e.NewValues["rptPriority"] = ctlPriority.Checked ? 1 : 0;
}
The following is a stub from the save / update code behind.
protected void btnSave_OnCLick(object sender, EventArgs e)
{
RadioButtonList rblReportStatus = (RadioButtonList)dvReport.FindControl("rblReportStatus");
using (RiderReportDataContext db = new RiderReportDataContext())
{
Report report = null;
Contact contact = null;
DateTime now = DateTime.Now;
bool doUpdate = false;
ldsContact.Updating += (o, ea) =>
{
Contact original = (Contact)ea.OriginalObject;
contact = (Contact)ea.NewObject;
if (
original.FirstName != contact.FirstName ||
...
original.Email != contact.Email)
{
doUpdate = true;
}
db.Contacts.Attach(contact, original);
ea.Cancel = true;
};
// force the update procedure
dvContact.UpdateItem(true);
ldsReport.Updating += (o, ea) =>
{
Report original = ea.OriginalObject as Report;
report = ea.NewObject as Report;
if (rblReportStatus.SelectedItem != null)
{
report.ReportStatusId = int.Parse(rblReportStatus.SelectedValue);
}
if (
original.ReportStatusId != report.ReportStatusId ||
original.SourceId != report.SourceId ||
...
original.ReportTypeID != report.ReportTypeID ||
original.rptPriority != report.rptPriority || // The value here doesn't change
original.SupervisorId != report.SupervisorId)
{
doUpdate = true;
}
db.Reports.Attach(report, original);
ea.Cancel = true;
};
// force the update procedure
dvReport.UpdateItem(true);
// Other Search For Updates
if (doUpdate)
{
contact.ChangedOn = now;
report.ChangedOn = now;
Log log = new Log();
log.ReportId = report.Id;
log.UserId = MembershipClass.User.Id;
log.Text = "The report updated.";
log.CreatedOn = now;
report.Logs.Add(log);
db.SubmitChanges();
}
}
if (Page.IsValid)
{
Response.Redirect("~/default.aspx" /*table.ListActionPath */);
}
}

As you've discovered, Bind() doesn't provide an easy way to convert a data type. You will find other answers which suggest changing the type of the data you are binding to, but I understand this isn't an option in your case.
I think your best solution is to go back to one-way binding. e.g. use your existing code:
<asp:CheckBox ID="Priority" runat="server"
Checked='<%# Convert.ToBoolean(Eval("rptPriority")) %>' />
Which will correctly set the value of the checkbox when the DetailsView is rendered, but will not provide a value for rptPriority when the details are updated. For this you'll need to add an OnItemUpdating event handler to your DetailsView, which will allow you to perform the custom conversion your need. e.g.
<asp:DetailsView ID="dvReport" runat="server"
onitemupdating="dvReport_ItemUpdating"
And the implementation in your code-behind will look like this:-
protected void dvReport_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
DetailsView dv = sender as DetailsView;
CheckBox ctlPriority = dv.FindControl("Priority") as CheckBox;
e.NewValues["rptPriority"] = ctlPriority.Checked ? 1 : 0;
}
Hope this helps.

Related

How do I embed a variable plus string in ASP:Label Text attribute?

Extremely new to ASPX, I'm attempting to update some existing code. I have a tag
asp:Label ID="lblProjectGoal" runat="server" Font-Bold="true"
Text=<%= SPCProjectYear %>+" Goals:"
AssociatedControlID="txbProjectGoal" />
and I need the year to be a variable that I can use in other <asp:Label> tags in the text attribute with differing string endings. Anyone know the best syntax to use here for Text=<%= SPCProjectYear %>+" Goals:"? Visual Studio tells me I have the syntax wrong. Thanks.
Private Label createLabelText(Label l, string SPCProjectYear){
l.Text = SPCProjectYear+" Goals:";
}
Label l = new Label();
l.ID = "lblProjectGoal";
l = createLabelText(l,SPCProjectYear);
Page.ControlsAdd(l);
(A clunky example -- would be optimized to add other things based on the source of your data)
Let me show it a little differently (this goes in code behind, where "myYear is the variable you're talking about)
string myYear = "2006";
protected void Page_Load(object sender, EventArgs e)
{
lblProjectGoal.Text = myYear + " Goals:";
}
Try to change the Label Text binding like this , I am assuming you missed EVAL and see if this works out
Text='<%# Eval(SPCProjectYear)%>+ Goals:'
Update
Add this method in CodeBehind
public string ProcessMyDataItem(object myValue)
{
if (myValue.ToString() != "")
{
return myValue.ToString() + "Goals" ;
}
}
In aspx
Text='<%# ProcessMyDataItem(Eval("SPCProjectYear")) %>'

ASP.net Speeding up the dropdownlist load by preloading its data from table

I have a grid view that uses dropdownlist to select employees ID but displaying names.
<EditItemTemplate>
<asp:DropDownList ID="DropDownList5" runat="server" AppendDataBoundItems="True" DataSourceID="SqlDataSourceEmployees" DataTextField="name" DataValueField="empID" SelectedValue='<%# Bind("employee") %>'>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
This works fine, but the SqlDataSourceEmployees is called the moment user clicks on the dropdownlist, which causes quite annoying delay, since as I understand first it fires a SQL command (simple SELECT empID,NAME FROM EMPLOYEES WHERE department=#department) and then the list is populated. It would be much better to bind the dropDowList to something that is already in memory, especially that I don't have to worry that the data in the list would change after page has been loaded.
I've thought about loading it to the DataTable on PageLoad and then binding such table to dropDownList but the list cannot find mentioned above table. I've even put the DataTable as public method of the webpage:
public partial class PlannersCurrentRoster : System.Web.UI.Page
{
private DataSet.employeesDataTable employeesTable;
public DataSet.employeesDataTable EmployeesTable
{
get { return employeesTable; }
set { employeesTable = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
DataSetTableAdapters.employeesTableAdapter TA = new DataSetTableAdapters.employeesTableAdapter();
DataSet.employeesDataTable empTable = TA.GetDataByDepartment(lblDepartment.Text);
EmployeesTable = empTable;
but then changing the bind of the list
<EditItemTemplate>
<asp:DropDownList ID="DropDownList5" runat="server" AppendDataBoundItems="True" DataSourceID="EmployeesTable" DataTextField="name" DataValueField="empID" SelectedValue='<%# Bind("employee") %>'>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
fails to find the "EmployesTable".
EDIT:
Following the solution below I've tried:
protected void GridView5_RowUpdating(object sender, GridViewUpdateEventArgs e)
{ ((DropDownList)GridView5.Rows[e.RowIndex].FindControl("DropDownList5")).DataSource = EmployeesTable;
((DropDownList)GridView5.Rows[e.RowIndex].FindControl("DropDownList5")).DataBind();
}
Which doesn't speed up things a bit, I'm sure that the DDL still takes data from SQL source (when I was trying to remove it, I had an error stating that SelevtedValue is invalid)
So I've tried to assign it one step earlier, during editing event
protected void GridView5_RowEditing(object sender, GridViewEditEventArgs e)
{
((DropDownList)GridView5.FindControl("DropDownList5")).DataSource = EmployeesTable;
((DropDownList)GridView5.FindControl("DropDownList5")).DataBind();
}
but then it fails to find dropdownlist5
EDIT: I give up. After reading this article I've simply changed SQLDataSource type to DataReader which indeed improved performance. Or maybe its the placebo effect for my tired mind.
You can't do it the way you have it since the your employeesTable variable is destroyed as soon as the page is served. Each postback then gets a new instance. If the list is not unique, instead store it into the Cache object. You can then set a timeout for it as well.
If it is based on data for the page, you can either store it in session which could carry it across pages but can degrade performance if you have a large number of objects storing in session across users.
If it's not too large you could store it in ViewState instead. It will then be serialised to the client. The downside is, the data can bloat the HTML sent to the client.
In your case, since the datatable seems to be dependent upon the a text field, it may be better to use the viewstate. In your case though, complexity is added due to the fact you need to know when the text value has changed as well so you can negate the data.
The following is a crude example of ViewState but you can also adapt for Session and the Cache.
private string SelectedDepartmentText
{
get
{
if(ViewState["SelectedDepartmentText"] != null)
return ViewState["SelectedDepartmentText"].ToString();
else
return string.Empty;
}
set{ViewState["SelectedDepartmentText"] = value;}
}
public DataSet.employeesDataTable EmployeesTable
{
get
{
if(!SelectedDepartmentText.Equals(lblDepartment.Text))
{
// if the SelectedDepartmentText isn't the same as the lblDepartment.Text, go fetch it
DataSetTableAdapters.employeesTableAdapter TA = new DataSetTableAdapters.employeesTableAdapter();
ViewState["EmployeesTable"] =TA.GetDataByDepartment(lblDepartment.Text);
// save the lblDepartment.Text value to the viewstate for next time.
SelectedDepartmentText = lblDepartment.Text;
return ViewState["EmployeesTable"];
}
else
{
// let's see if we have something already and return it
if(ViewState["EmployeesTable"] != null)
return (DataSet.employeesDataTable)ViewState["EmployeesTable"];
else
{
// if we don't, let's get it, this also handles an empty string for the
// lblDepartment.Text
DataSetTableAdapters.employeesTableAdapter TA = new DataSetTableAdapters.employeesTableAdapter();
// store it in the viewstate
ViewState["EmployeesTable"] =TA.GetDataByDepartment(lblDepartment.Text);
// and return whatever we got back
return (DataSet.employeesDataTable)ViewState["EmployeesTable"];
}
}
return null;
}
set{ ViewState["EmployeesTable"] = value;}
}

asp.net how can ObjectDataSource access System.Web.UI.Page objects

I use ObjectDataSource as below.
<asp:ObjectDataSource ID="Item" runat="server"
SelectMethod="Grid_DataBind" TypeName="XXX.XXX.XXX"
DataObjectTypeName="Controller.Items" UpdateMethod="UpdateRow_Grid"
InsertMethod="InsertRow_Grid">
When InsertMethod fire, everything work fine but ...
public IList<Items> InsertRow_Grid(Items item)
{
item.ID = System.Guid.NewGuid().ToString();
bool contains = GridSource.AsEnumerable()
.Any(row => item.JobID == row.JobID);
if (!contains)
{
GridSource.Add(item);
}
else
{
lblMsg.Text= "This record has already exists.";
}
return GridSource;
}
It doesn't know my label object which is presented in my aspx file.
I had read this so that I can search proper solution.
But I still don't get how to do.
Every suggestion will be appreciated.
This is because asp:ObjectDataSource creates new instance of object you specified in "TypeName" property
To use current page object instead of creating new, you need this code:
YourObjectDataSource.ObjectCreating += (s, a) => { a.ObjectInstance = this; };
Place it in Page_Load or Page_Init
You can add this code to your page
...
<asp:Label id="lblMsg" runat="server"/>
<asp:ObjectDataSource ID="Item" runat="server"
SelectMethod="Grid_DataBind" TypeName="XXX.XXX.XXX"
DataObjectTypeName="Controller.Items" UpdateMethod="UpdateRow_Grid"
InsertMethod="InsertRow_Grid">
.....

AJAXFileUpload with Title Textbox

Fairly straightforward. I'm just looking for users to be able to add a title to the file before uploading. (Yes, I encourage proper filenames, but that's not the point.)
<asp:TextBox runat="server" ID="txtDocumentTitle" />
<ajaxToolkit:AjaxFileUpload runat="server" ID="ajxUploadNDA" OnUploadComplete="ajxUpload_Complete" Width="400px" /><br />
protected void ajxUpload_Complete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
MyFile f = new MyFile();
f.DocumentType = e.ContentType;
f.FileBytes = e.GetContents();
f.FileName = e.FileName;
f.DocumentCategory = "Package Files";
f.FileUploaded = DateTime.Now;
f.DocumentTitle = txtDocumentTitle.Text;
f.Save();
DataBind();
}
However when setting a breakpoint, txtDocumentTitle.Text is always blank. I can't seem to force a full postback or find any other way to get the current value of that textbox. I can allow the user to edit those properties after the file is uploaded, but that is not the design I'd prefer for a few reasons. (It encourages leaving values at default.)
I've tried:
protected void Page_Init(object sender, EventArgs e)
{
ScriptManager.GetCurrent(Page).RegisterPostBackControl(ajxUploadNDA);
ScriptManager.GetCurrent(Page).SupportsPartialRendering = false;
ScriptManager.GetCurrent(Page).EnablePartialRendering = false;
}
and I've tried
<ajaxToolkit:AjaxFileUpload runat="server" ID="ajxUploadNDA" OnUploadComplete="ajxUpload_Complete" Width="400px" onchange="if (confirm('Upload ' + this.value + '?')) this.form.submit();" />
Any suggestions would be more than welcome.
I've sort of solved it by adding a button to "Set Document Title" which adds the value of the textbox to session. The ajxUpload_Complete function then uses this Session variable to set the title to that session value on upload.
It's sloppy for a couple reasons, but it's the best I could do.
On Page_Load:
if (!Page.IsPostBack && !ajxUploadNDA.IsInFileUploadPostBack)
{
Session.Remove("DefaultDocumentCategory");
lblDocumentCategory.Text = "Data Package Files";
Session.Remove("DefaultDocumentTitle");
lblDocumentTitle.Text = "Data Package File";
}
protected void btnChangeDocumentAttributes_Click(object sender, EventArgs e)
{
lblDocumentCategory.Text = cboDocumentCategory.SelectedValue;
lblDocumentTitle.Text = txtDocumentTitle.Text;
Session["DefaultDocumentCategory"] = lblDocumentCategory.Text;
Session["DefaultDocumentTitle"] = lblDocumentTitle.Text;
}
I also added a dummy button to the page to force a postback refreshing my gridview that shows all the files uploaded.
<asp:Button ID="btnForcePostBack" runat="server" Text="" Style="background-color: Transparent; color: inherit; border-style: none;" />
protected void ajxUpload_Complete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
MyFile f = new MyFile();
f.DocumentType = e.ContentType;
f.FileBytes = e.GetContents();
f.FileName = e.FileName;
f.FileUploaded = DateTime.Now;
if (Session["DefaultDocumentCategory"] == null || Session["DefaultDocumentCategory"].ToString() == string.Empty) f.DocumentCategory = "Data Package Files";
else f.DocumentCategory = Session["DefaultDocumentCategory"].ToString();
if (Session["DefaultDocumentTitle"] == null || Session["DefaultDocumentTitle"].ToString() == string.Empty) f.DocumentTitle = "Data Package File";
else f.DocumentTitle = Session["DefaultDocumentTitle"].ToString();
f.Save();
ajxUploadNDA.Page.ClientScript.RegisterStartupScript(this.GetType(), "RefreshParent", "<script type='text/javascript'>var btn = window.parent.document.getElementById('btnForcePostBack');if (btn) btn.click();</script>");
}
I couldn't get any of these other answers to work. I ended up putting the textbox on an ajax update panel. Then I created an event for the textbox OnTextboxChanged that stored the value in the session. Then I could grab the value in the UploadComplete right from the session.
When using ajax upload, you can only save right away, then second step would be to have separate call to get file from saved location and operate on it. I was having same issue with multiple asynchronous upload using Uploadify and Uploadifive. My first step when uploading multiple files is to save to temp location, then have second call to retrieve it, resize it and save it to cloud (Azure Storage). Its impossible to put a break point, since the threads are all over the place. Its a strange behavior, specially when uploading a single file, but that's the best solution to first save then retrieve using separate call.
The problem is that AjaxFleUpload control use hidden frame for submitting file content. You may use script below to pass textbox value to server:
Sys.Application.add_load(applicationLoadHandler);
function applicationLoadHandler() {
var originalCreateForm = Sys.Extended.UI.AjaxFileUpload.prototype._createVForm;
Sys.Extended.UI.AjaxFileUpload.prototype._createVForm = function () {
originalCreateForm.call(this);
var textBox = document.createElement("INPUT");
textBox.setAttribute("type", "text");
textBox.setAttribute("name", "<%= txtDocumentTitle.UniqueID %>");
textBox.setAttribute("value", document.getElementById("<%= txtDocumentTitle.ClientID %>").value);
this._vForm.appendChild(textBox);
}
}
On server you can get user input from Request.Form collection:
var title = Request.Form[txtDocumentTitle.UniqueID];

Launching a Edit Form from a GridButtonColumn

I have a class that defines a Hierarchical RadGrid that I will be using application wide. This grid has many column so this is the best implementation for me, as I will be overriding specific characteristics of the grid based om implementation.
The grid will function in a different manner based on the access level of the user. On a 'basic user level' they will have a Add New Item/Edit Item on the parent grid and Edit, Reject(delete), Approve(Update) on the Child Grid
The next level will be a 'Approver' role. They will NOT have Add New Item/Edit Item on the parent grid and will only have Reject(Edit) on the child. The edit action that the user will take in this role when rejecting an item is that they will be required to enter a comment through a user control that will be launched when the click the reject button. The problem that I am having is that the custom user control is not displaying for a DetailTableView.EditFormSettings when using a GridButtonColumn as the firing event. Any thoughts? TIA
private void SubmittedBatchesRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
GridDataItem _dataItem = e.Item as GridDataItem;
if (_dataItem == null) return;
if (e.Item.OwnerTableView.Name == "SubmittedBatchesRadGrid_ChildGrid")
{
SetChildGridCommandColumns(sender, e);
return;
}
if (_dataItem.KeyValues == "{}") { return; }
SetMasterGridCommandColumns(sender, e, _dataItem);
}
private static void SetChildGridCommandColumns(object sender, GridItemEventArgs e)
{
const string _jqueryCode = "if(!$find('{0}').confirm('{1}', event, '{2}'))return false;";
const string _confirmText = "<p>Rejecting this adjustment will mean that you will have to also reject the batch when you are done processing these items.</p><p>Are you sure you want to reject this adjustment?</p>";
((ImageButton)(((GridEditableItem)e.Item)["PolicyEditRecord"].Controls[0])).ImageUrl = "/controls/styles/images/editpencil.png";
ImageButton _btnReject = (ImageButton)((GridDataItem)e.Item)["DeleteTransaction"].Controls[0];
_btnReject.CommandName = "Update";
_btnReject.ImageUrl = "/controls/styles/images/decline.png";
_btnReject.ToolTip = "Reject this item";
//_btnReject.Attributes["onclick"] = string.Format(_jqueryCode, ((Control)sender).ClientID, _confirmText, "Reject Adjustment");
}
private void SubmittedBatchesRadGrid_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
e.DetailTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl;
e.DetailTableView.EditFormSettings.UserControlName = "/Controls/RejectedAdjustmentComment.ascx";
e.DetailTableView.EditMode = GridEditMode.PopUp;
e.DetailTableView.CommandItemSettings.ShowAddNewRecordButton = false;
GridDataItem _dataItem = e.DetailTableView.ParentItem;
e.DetailTableView.DataSource = AdjustmentAPI.GetAdjustmentsByBatch(Convert.ToInt32(_dataItem.GetDataKeyValue("BatchID").ToString()), PolicyClaimManualAdjustmentCode);
}
It looks like you just need to use OnClientClick instead, and return the value of the confirm dialog.
_btnReject.OnClientClick = "return confirm(\"Are you sure you?\");"
RadAjax has a little quirk when it comes to confirm dialogs, so you may need to use this instead:
_btnReject.OnClientClick = "if (!confirm(\"Are you sure?\")) return false;"
So I thought I would share my solution in case anyone else needs it.
I was barking up the wrong tree with the edit control. Even though a comment is part of the dataset in the RadGrid I don't want to edit the existing record. I decided to create a usercontrol to handle the process. The RadWindow does not take .ascx pages directly so I started with a .aspx wrapper page and inserted the control there. Then I changed the OnClientClick event to launch the RadWindow loading the new aspx file passing the parameters I needed to the usercontrol. The usercontrol saves the comment to the database and updates the record status and then closes.
I modified this section from above:
private static void SetChildGridCommandColumns(object sender, GridItemEventArgs e)
{
((ImageButton)(((GridEditableItem)e.Item)["PolicyEditRecord"].Controls[0])).ImageUrl = "/controls/styles/images/editpencil.png";
ImageButton _btnReject = (ImageButton)((GridDataItem)e.Item)["DeleteTransaction"].Controls[0];
int _manualAdjustmentId = Convert.ToInt32(((GridDataItem)e.Item)["ManualAdjustmentId"].Text);
int _manualAdjustmentBatchId = Convert.ToInt32(((GridDataItem)e.Item)["ManualAdjustmentBatchId"].Text);
_btnReject.ImageUrl = "/controls/styles/images/decline.png";
_btnReject.ToolTip = "Reject this item";
_btnReject.OnClientClick = String.Format("OpenRadWindow('/controls/RejectedAdjustmentComment.aspx?manualAdjustmentId={0}&manualAdjustmentBatchId={1}', 'CommentDialog');return false;", _manualAdjustmentId, _manualAdjustmentBatchId);
}
private void SubmittedBatchesRadGrid_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
//I deleted this section
e.DetailTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl;
e.DetailTableView.EditFormSettings.UserControlName = "/Controls/RejectedAdjustmentComment.ascx";
e.DetailTableView.EditMode = GridEditMode.PopUp;
//
e.DetailTableView.CommandItemSettings.ShowAddNewRecordButton = false;
GridDataItem _dataItem = e.DetailTableView.ParentItem;
e.DetailTableView.DataSource = AdjustmentAPI.GetAdjustmentsByBatch(Convert.ToInt32(_dataItem.GetDataKeyValue("BatchID").ToString()), PolicyClaimManualAdjustmentCode);
}
I added this to the page with the datagrid:
<telerik:RadWindowManager ID="SubmittedBatchesWindow" runat="server">
<windows>
<telerik:RadWindow ID="CommentDialog" runat="server" Title="Rejected Agjustment Comment Dialog"
Height="350px" Width="440" Left="250px" ReloadOnShow="false" ShowContentDuringLoad="false"
Modal="true" VisibleStatusbar="false" />
</windows>
</telerik:RadWindowManager>
I created a new aspx file and inserted the new ascx control inside
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<uc:RejectedComment id="RejectionComment1" runat="server" />
</form>
I added my code behind for the update in the ascx file, the javascript for the front end
<script language ="javascript" type ="text/javascript" >
//<![CDATA[
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
return oWindow;
}
function CancelEdit() {
GetRadWindow().close();
}
//]]>
</script>
and last but not least closing the window after a successful update in the button click event;
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "CancelEdit();", true);
I hope someone else finds this useful. It took me several hours hunting the telerik site to find this piece by piece.

Categories