Hi, I’m using Visual Studio 2008 and im trying to encapsulate an ultrawebgrid in a custom control using ASP.NET Server Control Project.
The code goes something like this:
Public Class GrillaCustom Inherits UltraWebGrid
Public Overrides Function OnAddRow(ByVal row As Infragistics.WebUI.UltraWebGrid.UltraGridRow) As Boolean
Return MyBase.OnAddRow(row)
End Function
End Class
I have generic client side events handlers and I want to include them into this custom control.
For example
function UWGCustom_AfterRowInsertHandler(gridName, rowId, index)
{ var oGrid = igtbl_getGridById(gridName);
document.getElementById("hdRowInserted").value=rowId oGrid.beginEditTemplate();
}
The problem is that the control only has the class file with the code behind (no .ascx file)...
So the question is how can I include the javascript code into the user control using the grid this way?
I also want to include in this control some custom buttons to update and cancel in order to use the batch events of the grid.
Is this possible??
Regards,
Daniel
Hello Daniel,
You can programmatically register javascript though a number of Page.ClientScript.RegisterrXXX methods. This is typically done in the control OnPreRender event (earlier or later in the lifecycle may have adverse effects on the logic).
More information on Page.ClientScript can be found in MSDN:
http://msdn.microsoft.com/en-us/library/system.web.ui.page.clientscript.aspx
Sorry the delay... I was offline for a while...
I followed your advice and now all it's working like a charm!. Thanks!!
Great! Glad I was able to help. Thanks for sharing the solution in public forums, this will certainly be helpful for a lot of developers.
Thanks again.