Using AutoComplete Ajax Toolkit Control under Umbraco.
I have developed a complex .NET User Control based on VS 2005 and .NET 2.0. The UC has about 5 AutoComplete Ajax Control targeted for .NET 2.0. Also, the same UC has EO.Web Grid Control and a .NET DetailsView with complete CRUD Operations, which are linked to CSLA .NET Business Objects.
All work fine under a traditional .NET Web Application Project using VS 2005.
Now, I am planning to deply this work under Umbraco.
I am have started deploying the above mentioned work under a new fresh successful installation of Umbraco 4.0.3.
As soon as I open the page which has the Macto/Use Control, under Umbraco, it will fail, and following is the error I get using:
"?umbdebugshowtrace=true".
Error creating usercontrol (/usercontrols/clinic/ucLabRequest.ascx) Could not load file or assembly 'AjaxControlToolkit, Version=1.0.20229.20821, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at umbraco.macro.loadUserControl(String fileName, Hashtable attributes, Hashtable pageElements)
Aparently, there is conflict between the AjaxControlToolkit I am using and that which is used by Umbraco.
How I can resolve this problem ?
Note: This is my first project which will go-live under Umbraco at work.
I was able to resolve all the problems mentioned above, however, I have now another problem.
It seems that the PostBack event is not being detected inside the Page_Load Event inside the User Control. I did debug under Umbraco, and found out that Inside the Page_Load Event, the property "Page.IsPostBack" is alwasy false. This means, everytime the User Control in run in a Post-Back Event, it will be sent as a new request.
Not only the "IsPostBack" event is always "false", also, the "TextChanged" event for the "TextBox" Server Control (inside the UC) is not being fired at all.
I created a code-behined for the Master Page I am using inside Umbraco, I did a test inside the "Page_Load" event of the Master Page, and I noticed that no mater what, the "IsPostBack" is alwasy "false".
I have tested my User Control from inside a traditional Web Project Application, and it is working successfully.
function fn_ee_LabTestKeyValue_timeout(cell) { cell.getGrid().editItem(cell.getItemIndex(), true) }
function fn_ee_LabTestKeyValue(cell) { var elmHTML; var elmID; //elmID = cell.getGrid().getId() + "_edit_" + txtLabTestKeyValue; elmHTML = $get("<%=txtLabTestKeyValue_ClientID()%>"); //document.getElementById(elmID); return elmHTML.value; }
function getOffset( elPrm ) { var _x = 0; var _y = 0; var el = elPrm; while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) { _x += el.offsetLeft; // - el.scrollLeft; _y += el.offsetTop; // - el.scrollTop; if (el != elPrm) { _y += el.clientTop; // - el.scrollTop; } el = el.parentNode; } return { top: _y, left: _x }; }
function txtLabTestKeyValue_OnClientShown(source, eventArgs){ //alert("OnClientShown"); var elmComp = source.get_completionList(); // var theGrid = eo_GetContainer(source.get_element() , 'Grid'); // var elmGrid = document.getElementById(theGrid.getId()); // var GridOffset = getOffset(elmGrid); // var GridIndex = parseInt(elmGrid.zIndex) // var CompBound = $common.getLocation(elmComp); var myAnchor = $get("txtLabTestKeyValue_anchor") $common.setLocation(elmComp, $common.getLocation(myAnchor)); // elmComp.style.posTop = CompOffset.top; // elmComp.style.posLeft = CompOffset.left; }
function timeOut_txtLabTestKeyValue() { //Get the "anchor" position var e = $get("anchor_txtLabTestKeyValue"); var b = $common.getBounds(e);
//Move the "editor" to the same position //and display the editor at the same time e = $get("editor_txtLabTestKeyValue"); e.style.display = ""; $common.setLocation(e, b); } //This function is called when the cell enters edit mode. //We dynamically align the "editor" div to "anchor div //in this function function begin_edit_txtLabTestKeyValue(cell) { //The call must be delayed with a timer because //at this moment "anchor" is not visible yet setTimeout(timeOut_txtLabTestKeyValue, 10); }
//This function is called when the cell exists //edit mode function end_edit_txtLabTestKeyValue(cell) { //Hide the editor var e = $get("editor_txtLabTestKeyValue"); e.style.display = "none";
//Return the new value to the Grid var input = $get("<%=txtLabTestKeyValue_ClientID()%>"); return input.value; }
Imports System.Web.UI Namespace Clinic Partial Public Class ucLabRequest Inherits System.Web.UI.UserControl
Private mLabRequestID As Integer Private mDoCreateLabRequest As Boolean = False Private StaffList As StaffIDNameValueList = StaffIDNameValueList.GetList()
Protected Function txtLabTestKeyValue_ClientID() As String Return CType(gridLabItems.Columns(1), EO.Web.CustomColumn).EditorInstance.FindControl("txtLabTestKeyValue").ClientID End Function Public Property LabRequestID() As Integer Get Dim theLabRequestID As Integer Try theLabRequestID = dvLabRequest.DataKey.Item("LabRequestID") mLabRequestID = theLabRequestID Catch ex As Exception theLabRequestID = mLabRequestID End Try Return mLabRequestID End Get Set(ByVal value As Integer) SearchPanel.Attributes.CssStyle.Item("display") = "none" If mLabRequestID <> value Then mLabRequestID = value txtLabRequestIDLookup.Text = mLabRequestID.ToString() mDoCreateLabRequest = False dvLabRequest.DataBind() End If End Set End Property
Public Property DoCreateLabRequest() As Boolean Get Dim result As Boolean Dim theLabRequest As LabRequest theLabRequest = GetLabRequest() If Not theLabRequest Is Nothing Then result = theLabRequest.IsNew() Else result = mDoCreateLabRequest End If Return result End Get Set(ByVal value As Boolean) mDoCreateLabRequest = True 'dvLabRequest.DefaultMode = WebControls.DetailsViewMode.Insert dvLabRequest.ChangeMode(WebControls.DetailsViewMode.Insert) End Set End Property Private Function GetLabRequest() As LabRequest Dim theLabRequest As LabRequest = Nothing Try If TypeOf Session("BusinessObject") Is LabRequest Then theLabRequest = CType(Session("BusinessObject"), LabRequest) Else Session("BusinessObject") = Nothing End If Catch ex As Exception Session("BusinessObject") = Nothing End Try If theLabRequest Is Nothing Then ProcesstxtLabRequestIDLookup(True) End If If (mLabRequestID > 0 AndAlso theLabRequest Is Nothing) _ OrElse _ (Not theLabRequest Is Nothing AndAlso mLabRequestID > 0 AndAlso mLabRequestID <> theLabRequest.LabRequestID) _ Then theLabRequest = LabRequest.GetLabRequest(mLabRequestID) Session("BusinessObject") = theLabRequest End If If (mDoCreateLabRequest AndAlso Not theLabRequest Is Nothing AndAlso Not theLabRequest.IsNew()) _ OrElse _ (mDoCreateLabRequest AndAlso theLabRequest Is Nothing) Then theLabRequest = LabRequest.NewLabRequest() Session("BusinessObject") = theLabRequest mLabRequestID = 0 End If mDoCreateLabRequest = False If Not theLabRequest Is Nothing Then If theLabRequest.IsNew() Then txtLabRequestIDLookup.Text = "[new]" Else txtLabRequestIDLookup.Text = theLabRequest.LabRequestID() End If Else txtLabRequestIDLookup.Text = "" End If Return theLabRequest End Function
Private Function SaveLabRequest(ByVal theLabRequest As LabRequest, Optional ByVal DoRaiseErrors As Boolean = False) As Integer
Dim rowsAffected As Integer Try Session("BusinessObject") = theLabRequest.Save() mLabRequestID = theLabRequest.LabRequestID rowsAffected = 1 mDoCreateLabRequest = False Catch ex As Csla.Validation.ValidationException If DoRaiseErrors Then GlobalFunctions.PreserveStackTrace(ex) Throw 'New Csla.Validation.ValidationException(ex.Message, ex) End If Dim message As New System.Text.StringBuilder message.AppendFormat("{0}<br/>", ex.Message) If theLabRequest.BrokenRulesCollection.Count = 1 Then message.AppendFormat("* {0}: {1}", _ theLabRequest.BrokenRulesCollection(0).Property, _ theLabRequest.BrokenRulesCollection(0).Description)
Else For Each rule As Csla.Validation.BrokenRule In _ theLabRequest.BrokenRulesCollection message.AppendFormat( _ "* {0}: {1}<br/>", rule.Property, rule.Description) Next End If Me.ErrorLabel.Text = message.ToString rowsAffected = 0
Catch ex As Csla.DataPortalException If DoRaiseErrors Then GlobalFunctions.PreserveStackTrace(ex) Throw ' New Csla.DataPortalException(ex.Message, ex) End If Me.ErrorLabel.Text = ex.BusinessException.Message rowsAffected = 0
Catch ex As Exception If DoRaiseErrors Then GlobalFunctions.PreserveStackTrace(ex) Throw ' New Csla.DataPortalException(ex.Message, ex) End If Me.ErrorLabel.Text = ex.Message rowsAffected = 0 End Try Return rowsAffected
End Function
Protected Sub dtaLabRequest_SelectObject(ByVal sender As System.Object, ByVal e As Csla.Web.SelectObjectArgs) Handles dtaLabRequest.SelectObject Try Dim theLabRequest As LabRequest theLabRequest = GetLabRequest() e.BusinessObject = theLabRequest If Not theLabRequest Is Nothing Then gridLabItems.DataSource = theLabRequest.RequestItems Else gridLabItems.DataSource = Nothing gridLabItems.Items.Clear() End If gridLabItems.DataBind() Catch ex As Csla.DataPortalException Me.ErrorLabel.Text = ex.BusinessException.Message gridLabItems.DataSource = Nothing gridLabItems.Items.Clear() Catch ex As Exception Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace gridLabItems.DataSource = Nothing gridLabItems.Items.Clear() End Try End Sub
Protected Sub dtaLabRequest_UpdateObject(ByVal sender As System.Object, ByVal e As Csla.Web.UpdateObjectArgs) Handles dtaLabRequest.UpdateObject 'Dim MyDtaSrc As Csla.Web.CslaDataSource Dim obj As LabRequest = GetLabRequest() Try Csla.Data.DataMapper.Map(e.Values, obj) Catch ex As Csla.Validation.ValidationException Me.ErrorLabel.Text = ex.Message Catch ex As Csla.DataPortalException Me.ErrorLabel.Text = ex.BusinessException.Message Catch ex As eHRMDException Me.ErrorLabel.Text = ex.Message Catch ex As Exception Me.ErrorLabel.Text = ex.Message End Try e.RowsAffected = SaveLabRequest(obj) End Sub
Protected Sub dtaLabRequest_InsertObject(ByVal sender As System.Object, ByVal e As Csla.Web.InsertObjectArgs) Handles dtaLabRequest.InsertObject
Try Dim obj As LabRequest = LabRequest.NewLabRequest() Csla.Data.DataMapper.Map(e.Values, obj, "LabRequestId") e.RowsAffected = SaveLabRequest(obj) Catch ex As Csla.Validation.ValidationException e.RowsAffected = 0 Me.ErrorLabel.Text = ex.Message Catch ex As System.ArgumentException If Not ex.InnerException Is Nothing AndAlso Not ex.InnerException.InnerException Is Nothing Then e.RowsAffected = 0 Me.ErrorLabel.Text = ex.InnerException.InnerException.Message Else Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace End If Catch ex As Csla.DataPortalException e.RowsAffected = 0 Me.ErrorLabel.Text = ex.BusinessException.Message Catch ex As eHRMDException e.RowsAffected = 0 Me.ErrorLabel.Text = ex.Message Catch ex As Exception e.RowsAffected = 0 Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace End Try
End Sub
Sub ProcesstxtLabRequestIDLookup(Optional ByVal DoSkipBind As Boolean = False) Dim theLabRequestID As Integer If dvLabRequest.CurrentMode = WebControls.DetailsViewMode.ReadOnly Then If IsNumeric(txtLabRequestIDLookup.Text) Then theLabRequestID = Convert.ToInt32(txtLabRequestIDLookup.Text) ElseIf String.IsNullOrEmpty(txtLabRequestIDLookup.Text.Trim) Then ' Nothing txtLabRequestIDLookup.Text = "" theLabRequestID = -1 Else Me.ErrorLabel.Text = "LabRequestID '" & txtLabRequestIDLookup.Text & "' must be numeric value." txtLabRequestIDLookup.Text = "" theLabRequestID = -1 End If If LabRequestID <= 0 OrElse (theLabRequestID > 0 AndAlso LabRequestID <> theLabRequestID) Then 'Restart() mLabRequestID = theLabRequestID mDoCreateLabRequest = False If Not DoSkipBind Then dvLabRequest.DataBind() End If End If End If End Sub
Protected Sub txtLabRequestIDLookup_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLabRequestIDLookup.TextChanged Try ProcesstxtLabRequestIDLookup() Catch ex As Exception Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace End Try End Sub
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim theLabRequestID As String Try
If IsPostBack Then 'ProcesstxtLabRequestIDLookup() Me.ErrorLabel.Text = "" Else theLabRequestID = Request.QueryString("LabRequestID") If Not String.IsNullOrEmpty(theLabRequestID) Then Me.LabRequestID = theLabRequestID Response.Redirect(Page.ResolveClientUrl(Page.Request.Path)) End If End If Catch ex As Exception Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace End Try End Sub Private Sub Restart() Try Dim dtaSrcIDSave As String Session("BusinessObject") = Nothing dvLabRequest.DefaultMode = WebControls.DetailsViewMode.ReadOnly dvLabRequest.ChangeMode(WebControls.DetailsViewMode.ReadOnly) txtLabRequestIDLookup.Text = "" mLabRequestID = -1 dtaSrcIDSave = dvLabRequest.DataSourceID dvLabRequest.DataSourceID = "" dvLabRequest.DataBind() dvLabRequest.DataSourceID = dtaSrcIDSave RestartLabItems() Catch ex As Exception End Try End Sub Private Sub dvLabRequest_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handles dvLabRequest.ItemCommand Dim myDV As WebControls.DetailsView myDV = sender If (e.CommandName = "Restart") Or _ (e.CommandName = "Cancel" And myDV.CurrentMode = WebControls.DetailsViewMode.Insert) Then Restart() End If End Sub
Private Sub dvLabRequest_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvLabRequest.ItemCreated Dim myDV As WebControls.DetailsView Dim txtLabRequestDateDMYStr As WebControls.TextBox myDV = sender If myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then Dim theLabRequest As LabRequest = GetLabRequest() txtLabRequestDateDMYStr = myDV.FindControl("txtLabRequestDateDMYStr") If Not txtLabRequestDateDMYStr Is Nothing AndAlso Not theLabRequest Is Nothing Then txtLabRequestDateDMYStr.Text = theLabRequest.LabRequestDate.ToString("dd/MM/yyyy") End If End If
End Sub
Private Sub dvLabRequest_ItemDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewDeletedEventArgs) Handles dvLabRequest.ItemDeleted dvLabRequest.DataBind() End Sub
Private Sub dvLabRequest_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles dvLabRequest.ItemInserted Dim myDV As WebControls.DetailsView myDV = sender If e.AffectedRows <= 0 Then e.KeepInInsertMode = True End If
End Sub
Private Sub dvLabRequest_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles dvLabRequest.ItemInserting Dim myDV As WebControls.DetailsView myDV = sender
End Sub
Private Sub RestartLabItems() Session("ChangedItems") = Nothing Session("DeletedItems") = Nothing gridLabItems.DataSource = Nothing gridLabItems.Items.Clear() gridLabItems.SelectedItemIndex = -1 gridLabItems.DataBind() End Sub
Private Sub dvLabRequest_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvLabRequest.ModeChanged Dim myDV As WebControls.DetailsView myDV = sender If myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then mDoCreateLabRequest = True RestartLabItems() End If
End Sub
Private Sub dvLabRequest_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles dvLabRequest.ModeChanging Dim myDV As WebControls.DetailsView Dim theLabRequest As LabRequest myDV = sender theLabRequest = GetLabRequest() If e.CancelingEdit AndAlso Not theLabRequest Is Nothing AndAlso theLabRequest.IsNew() Then Session("BusinessObject") = Nothing End If
End Sub
Private Sub dvLabRequest_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvLabRequest.PreRender Dim myDV As System.Web.UI.WebControls.DetailsView
Dim theTxtBoxWidth As WebControls.Unit = WebControls.Unit.Parse("370px")
Dim thePatientIDNameFld As WebControls.DataControlField Dim txtPatientIDName As WebControls.TextBox Dim idxPateint As Integer
Dim theTechnicianIDNameFld As WebControls.DataControlField Dim lblTechnicianIDName As WebControls.Label Dim idxTechnician As Integer
Dim theDoctorIDNameFld As WebControls.DataControlField Dim txtDoctorIDName As WebControls.TextBox Dim idxDoctor As Integer
Dim theDiagnosisIDFld As WebControls.DataControlField Dim txtDiagnosisIDDesc As WebControls.TextBox Dim idxDiagnosis As Integer
Dim theLabCommentsFld As WebControls.DataControlField Dim txtLabComments As WebControls.TextBox Dim idxLabComments As Integer Dim LabCommentsCtrl As WebControls.TableCell
myDV = sender Try
thePatientIDNameFld = GetDataControlField(myDV, "PatientIDName") If Not thePatientIDNameFld Is Nothing Then idxPateint = myDV.Fields.IndexOf(thePatientIDNameFld) If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then thePatientIDNameFld.HeaderText = "Lookup Patient ID - Name (partial match OK): " Else thePatientIDNameFld.HeaderText = "Patient ID - Name: " End If End If
theTechnicianIDNameFld = GetDataControlField(myDV, "TechnicianIDName") If Not theTechnicianIDNameFld Is Nothing Then idxTechnician = myDV.Fields.IndexOf(theTechnicianIDNameFld) If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then theTechnicianIDNameFld.HeaderText = "Technician ID - Name (Authenticated User): " Else theTechnicianIDNameFld.HeaderText = "Technician ID - Name: " End If End If
theDoctorIDNameFld = GetDataControlField(myDV, "DoctorIDName") If Not theDoctorIDNameFld Is Nothing Then idxDoctor = myDV.Fields.IndexOf(theDoctorIDNameFld) If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then theDoctorIDNameFld.HeaderText = "Lookup Doctor ID - Name (partial match OK): " Else theDoctorIDNameFld.HeaderText = "Doctor ID - Name: " End If End If
theDiagnosisIDFld = GetDataControlField(myDV, "DiagnosisIDDesc") If Not theDiagnosisIDFld Is Nothing Then idxDiagnosis = myDV.Fields.IndexOf(theDiagnosisIDFld) If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then theDiagnosisIDFld.HeaderText = "Lookup Diagnosis ID - Desc (partial match OK): " Else theDiagnosisIDFld.HeaderText = "Diagnosis ID - Desc: " End If End If
theLabCommentsFld = GetDataControlField(myDV, "LabComments") If Not theDiagnosisIDFld Is Nothing Then idxLabComments = myDV.Fields.IndexOf(theLabCommentsFld) Else idxLabComments = -1 End If
If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then txtPatientIDName = myDV.FindControl("txtPatientIDName") If Not txtPatientIDName Is Nothing Then txtPatientIDName.Width = theTxtBoxWidth End If If idxPateint < myDV.Rows.Count Then myDV.Rows(idxPateint - 1).Attributes.CssStyle.Item("display") = "none" myDV.Rows(idxPateint - 2).Attributes.CssStyle.Item("display") = "none" End If
Dim LoggedInUser = Security.GetWindowsLoginIDWeb() Dim StaffItem As StaffIDNameValueList.NameValuePair lblTechnicianIDName = myDV.FindControl("lblTechnicianIDName") If Not lblTechnicianIDName Is Nothing Then lblTechnicianIDName.Width = theTxtBoxWidth StaffItem = StaffList.LookupByKey(LoggedInUser) If Not StaffItem Is Nothing Then lblTechnicianIDName.Text = StaffItem.Value Else Throw New eHRMDException("Error: Logged in user ID '" & LoggedInUser & "' was not found.") End If End If If idxTechnician < myDV.Rows.Count Then myDV.Rows(idxTechnician - 1).Attributes.CssStyle.Item("display") = "none" myDV.Rows(idxTechnician - 2).Attributes.CssStyle.Item("display") = "none" End If
txtDoctorIDName = myDV.FindControl("txtDoctorIDName") If Not txtDoctorIDName Is Nothing Then txtDoctorIDName.Width = theTxtBoxWidth End If If idxDoctor < myDV.Rows.Count Then myDV.Rows(idxDoctor - 1).Attributes.CssStyle.Item("display") = "none" myDV.Rows(idxDoctor - 2).Attributes.CssStyle.Item("display") = "none" End If
txtDiagnosisIDDesc = myDV.FindControl("txtDiagnosisIDDesc") If Not txtDiagnosisIDDesc Is Nothing Then txtDiagnosisIDDesc.Width = theTxtBoxWidth End If If idxDiagnosis < myDV.Rows.Count Then myDV.Rows(idxDiagnosis - 1).Attributes.CssStyle.Item("display") = "none" myDV.Rows(idxDiagnosis - 2).Attributes.CssStyle.Item("display") = "none" End If
If Not theLabCommentsFld Is Nothing Then txtLabComments = myDV.Rows(idxLabComments).Cells(1).Controls(0) txtLabComments.TextMode = WebControls.TextBoxMode.MultiLine txtLabComments.Width = theTxtBoxWidth End If
ElseIf myDV.CurrentMode = System.Web.UI.WebControls.DetailsViewMode.ReadOnly Then If idxPateint < myDV.Rows.Count Then myDV.Rows(idxPateint).Attributes.CssStyle.Item("display") = "none" End If
If idxTechnician < myDV.Rows.Count Then myDV.Rows(idxTechnician).Attributes.CssStyle.Item("display") = "none" End If
If idxDoctor < myDV.Rows.Count Then myDV.Rows(idxDoctor).Attributes.CssStyle.Item("display") = "none" End If
If idxDiagnosis < myDV.Rows.Count Then myDV.Rows(idxDiagnosis).Attributes.CssStyle.Item("display") = "none" End If
Dim newDiv As HtmlControls.HtmlGenericControl If idxLabComments >= 0 And idxLabComments < myDV.Rows.Count Then LabCommentsCtrl = myDV.Rows(idxLabComments).Cells(1) newDiv = New HtmlControls.HtmlGenericControl("div") newDiv.InnerHtml = LabCommentsCtrl.Text LabCommentsCtrl.Text = "" LabCommentsCtrl.Controls.Add(newDiv) End If End If Catch ex As Exception myDV.ChangeMode(WebControls.DetailsViewMode.ReadOnly) Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace End Try
End Sub
Protected Sub lnkAddRequest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkAddRequest.Click DoCreateLabRequest = True RestartLabItems() End Sub
Protected Sub dtaLabRequest_DeleteObject(ByVal sender As System.Object, ByVal e As Csla.Web.DeleteObjectArgs) Handles dtaLabRequest.DeleteObject
Try LabRequest.DeleteLabRequest(e.Keys("LabRequestID")) Session("BusinessObject") = Nothing txtLabRequestIDLookup.Text = "" mLabRequestID = 0 e.RowsAffected = 1 Catch ex As Csla.DataPortalException Restart() Me.ErrorLabel.Text = ex.BusinessException.Message e.RowsAffected = 0 Catch ex As Exception Restart() Me.ErrorLabel.Text = ex.Message e.RowsAffected = 0 End Try End Sub
Protected Sub dtaLabRequestItems_SelectObject(ByVal sender As System.Object, ByVal e As Csla.Web.SelectObjectArgs) Handles dtaLabRequestItems.SelectObject Dim theLabRequest As LabRequest theLabRequest = GetLabRequest() If theLabRequest Is Nothing Then e.BusinessObject = Nothing Else e.BusinessObject = theLabRequest.RequestItems End If
End Sub
Private Sub gridLabItems_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridLabItems.DataBinding Dim myGrid As EO.Web.Grid myGrid = sender End Sub
Private Sub gridLabItems_ItemAdded(ByVal sender As Object, ByVal e As EO.Web.GridItemEventArgs) Handles gridLabItems.ItemAdded Dim myGrid As EO.Web.Grid myGrid = sender End Sub
Protected Sub gridLabItems_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gridLabItems.Load Dim myGrid As EO.Web.Grid myGrid = sender myGrid.Attributes.Item("onkeyup") = "LabRequestItemsGridKeyUp()" End Sub
Private Sub gridLabItems_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridLabItems.PreRender Dim myGrid As EO.Web.Grid myGrid = sender End Sub
Protected Sub dtaLabRequestItems_UpdateObject(ByVal sender As System.Object, ByVal e As Csla.Web.UpdateObjectArgs) Handles dtaLabRequestItems.UpdateObject Dim myDtaSrc As Csla.Web.CslaDataSource myDtaSrc = sender End Sub
Public Sub ApplyGridChanges(ByVal theLabRequest As LabRequest) Dim theLabItems As LabRequestItems Dim theLabItem As LabRequestItem Dim theGridItems As EO.Web.GridItem() = Nothing
Dim theChangedItemsArrList As List(Of EO.Web.GridItem) = New List(Of EO.Web.GridItem) Dim theChangedItems As EO.Web.GridItem() = Nothing
Dim theDeletedItemsArrList As List(Of EO.Web.GridItem) = New List(Of EO.Web.GridItem) Dim theDeletedItems As EO.Web.GridItem() = Nothing
Try Dim itm As EO.Web.GridItem Dim IsItmFound As Boolean = False Dim itmIdx As Integer = 0 Dim itm2Idx As Integer = 0 Dim itm2 As EO.Web.GridItem ' Get the failed Changed Items in the last post back theChangedItems = CType(Session("ChangedItems"), EO.Web.GridItem()) If Not theChangedItems Is Nothing Then theChangedItemsArrList.AddRange(theChangedItems) End If
' Get the failed Deleted Items in the last post back theDeletedItems = CType(Session("DeletedItems"), EO.Web.GridItem()) If Not theDeletedItems Is Nothing Then theDeletedItemsArrList.AddRange(theDeletedItems) End If
' Get copy of new deleted items from the Grid. For Each itm In gridLabItems.DeletedItems theDeletedItemsArrList.Add(itm) Next
' Remove Duplicates of Changed Items by comparing each item ' with the new changed items For Each itm In gridLabItems.ChangedItems If Not String.IsNullOrEmpty(itm.Key) Then itm2Idx = 0 IsItmFound = False For Each itm2 In theChangedItemsArrList.ToArray() If itm.Key.ToString = itm2.Key.ToString Then ' Same Key Value? Remove it ! theChangedItemsArrList.Remove(itm2) IsItmFound = True Exit For End If itm2Idx += 1 Next If IsItmFound Then theChangedItemsArrList.Insert(itm2Idx, itm) Else theChangedItemsArrList.Add(itm) End If Else Throw New Exception("Unexpected error: Null key value for Changed Item of LabKeyValue '" + itm.Cells("1").Value + "'.") End If Next ' Insert the new Added Items from the Grid to the list ' Generate Dummy Key Value itmIdx = -1 Dim tempKey As Integer For Each itm In gridLabItems.Items ' these are the item that failed to be added in a previous post-back If Not String.IsNullOrEmpty(itm.Key) AndAlso itm.Key.ToString.IndexOf("N*") >= 0 Then ' get greatest value tempKey = Convert.ToInt16(itm.Key.ToString.Substring(itm.Key.ToString.IndexOf("N*") + 2)) If tempKey > itmIdx Then itmIdx = tempKey End If End If Next If itmIdx < 0 Then itmIdx = 1 Else itmIdx += 1 End If For Each itm In gridLabItems.AddedItems itm.Key = "N*" & itmIdx itm.Cells(0).Value = itm.Key theChangedItemsArrList.Add(itm) itmIdx += 1 Next Session("ChangedItems") = Nothing Session("DeletedItems") = Nothing Try ' Update the changed items New Array List to Database. ' In case of any error, save the changed items for next post-back If Not theLabRequest Is Nothing Then theLabItems = theLabRequest.RequestItems If Not theLabItems Is Nothing Then ' Apply Database Updates for Changed Items Dim updItem As EO.Web.GridItem Dim ItemKey As String Dim theLabTestKeyValue As String Dim theLabResult As String ' Process Deletions of for deleted items that were saved to Database theDeletedItems = theDeletedItemsArrList.ToArray() For Each updItem In theDeletedItems ItemKey = updItem.Key.ToString ' first search for lab item by Key If ItemKey.IndexOf("N*") < 0 Then theLabItem = theLabItems.FindItem(Convert.ToInt16(ItemKey)) If Not theLabItem Is Nothing Then ' found ? Mark for deletion. theLabItems.Remove(theLabItem) theDeletedItemsArrList.Remove(updItem) Else 'no problem End If End If Next ' Process Updates and Inserts theChangedItems = theChangedItemsArrList.ToArray() For Each updItem In theChangedItems ItemKey = updItem.Key.ToString If ItemKey.IndexOf("N*") < 0 Then theLabItem = theLabItems.FindItem(Convert.ToInt16(ItemKey)) Else theLabItem = Nothing End If If Not theLabItem Is Nothing Then ' Update theLabItem.LabTestKeyValue = updItem.Cells("LabTestKeyValue").Value theLabItem.LabTestResult = updItem.Cells("LabTestResult").Value Else ' Insert theLabTestKeyValue = updItem.Cells("LabTestKeyValue").Value theLabResult = updItem.Cells("LabTestResult").Value theLabRequest.RequestItems.AddLabRequestItem(theLabTestKeyValue, theLabResult) theChangedItemsArrList.Remove(updItem) End If Next ' Process Deletions of items that were deleted from the grid theDeletedItems = theDeletedItemsArrList.ToArray() For Each updItem In theDeletedItems If Not String.IsNullOrEmpty(updItem.Key) Then ItemKey = updItem.Key.ToString ' if this is a new item, then search by LabTestKeyValue. theLabItem = theLabItems.FindItemByKeyValue(updItem.Cells("LabTestKeyValue").Value) If Not theLabItem Is Nothing Then ' found ? Mark for deletion. If theLabItem.IsNew() Then theLabItems.Remove(theLabItem) End If Else End If End If ' in any case, remove this deleted item from the saved array list. theDeletedItemsArrList.Remove(updItem) Next End If End If SaveLabRequest(theLabRequest, True) gridLabItems.DataSource = theLabRequest.RequestItems gridLabItems.DataBind() Catch ex As Exception If theChangedItemsArrList.Count > 0 Then Session("ChangedItems") = CType(theChangedItemsArrList.ToArray(), EO.Web.GridItem()) Else Session("ChangedItems") = Nothing End If If theDeletedItemsArrList.Count > 0 Then Session("DeletedItems") = CType(theDeletedItemsArrList.ToArray(), EO.Web.GridItem()) Else Session("DeletedItems") = Nothing End If Me.ErrorLabel.Text = ex.Message End Try
Catch ex As Exception ' ' Failed during saving of the post-back changed/deleted items ? ' Clear the chached items and reset the grid. ' Session("ChangedItems") = Nothing gridLabItems.DataSource = theLabRequest.RequestItems gridLabItems.DataBind() ' to Make sure the Grid is Synchronized with the Datasource. Me.ErrorLabel.Text = "Unexpected Error while saving the new changed/deleted items for next post-back. All changes will be lost. See error details below:<br/>" & ex.Message & "<br/>" & ex.StackTrace End Try
End Sub
Protected Sub btnSaveLabItems_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveLabItems.Click Dim theLabRequest As LabRequest theLabRequest = GetLabRequest() ApplyGridChanges(theLabRequest)
End Sub
Protected Sub btnTestLabReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestLabReport.Click Dim theLabRequest As LabRequest Dim theLabReport As LabReport01PDF theLabRequest = GetLabRequest() theLabReport = New LabReport01PDF(theLabRequest.LabRequestID) Response.Clear() theLabReport.Render(Response) Response.End() End Sub End Class
I can't see any obvious errors. How about creating a new macro, and dissect the complex control and add part by part to the new control? That way, you'll know where it starts to break. Than perhaps we can narrow down what the problem seems to be.
Great I dea ... this is the only way. I will do that .... the only problem is that the Clinic Staff have committed a schedule to start the with new system.
By the way, this Clinic system was originally developed under DNN, and I decided to re-write it based on Ajax and User Controls to allow faster Data Entry. Under DNN, it was very sloooooow ... cause the user have to navigate among 5 screens to do simple updates. If I hope I can deploy it under Umbraco.
If I am unable to nail down the problem, I will have to use the Tranditional Web Application Project instead of Umbraco.
Well, using a traditional Web Application Project is a short-term solution. If you get it working under Umbraco it will save you a lot of time with future development.
Try taking baby-steps, examine where the problem occurs and keep us posted. We will try to assist you from there.
If I delete the above <asp:LinkButton> Control, it workes, and I see the events are being executed and "IsPostBack" is working fine.
Also, if I keep this control and set the value of "PostBackUrl" to empty string, it works.
If I put any value for "PostBackUrl" the problem is back again. Even if I put a valid URL or even "#" !!!! This button will navigate from the Laboratory Entry Screen back to the Search Screen.
Do you think this is a bug in Umbraco ? Should I report it ?
Let me move now to finding a workaround:
Can you help me please ?
I have 2 main screens in this application. Each Screen is a Macro User Control.
Screen 1: Search Laboratory Requests. Here the user will use extermly flexible criteria to locate the Lab Request. When he clicks on an item in the ASP GridView, he must move to the Labroratory Request Entry Screen. Here is the code-behined for SelectedIndexChanged:
Protected Sub gvLabRequestList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gvLabRequestList.SelectedIndexChanged Dim myGV As System.Web.UI.WebControls.GridView myGV = sender Response.Redirect("LabRequestTest.aspx?LabRequestID=" & Me.SelectedLabRequestID) End Sub
As you can see, I am hard-coding the URL of the second screen in the Traditional Web Application Project.
Screen 2: Laboratory Request Entry Screen. In this screen, the user will maintain the request entry and all its details. He can click on "Search Laboratory Request" to move back to the search screen, as you have seen in the link button above. But, I am hard-coding the URL.
Now, in Umbraco, what is the best way to implement this kind of navigation ?
To get dynamic links to a Node in Umbraco you can use:
umbraco.library.NiceUrl(int NodeId)
If the only purpose of that button is to link back to the search-page I would use an asp:HyperLink instead. That would give a cleaner html. But it shouldn't really matter.
Before you post it as a bug in Umbraco I would make certain what the button with postbackurl is acctually doing, using fiddler or something alike. It should try to post to a new page. I'm not really sure why it returns to the same page. That sounds fishy.
Using AutoComplete Ajax Toolkit Control under Umbraco.
I have developed a complex .NET User Control based on VS 2005 and .NET 2.0. The UC has about 5 AutoComplete Ajax Control targeted for .NET 2.0. Also, the same UC has EO.Web Grid Control and a .NET DetailsView with complete CRUD Operations, which are linked to CSLA .NET Business Objects.
All work fine under a traditional .NET Web Application Project using VS 2005.
Now, I am planning to deply this work under Umbraco.
I am refering to this article:
http://our.umbraco.org/wiki/how-tos/adding-ajaxcontroltoolkit-v3-support-to-umbraco
Based on my understanding, there should be no problem, right ?
There will be a problem if I am using Ajax Toolkit for VS 2008, and then I have to follow the instruction in this article.
Tarek.
I am have started deploying the above mentioned work under a new fresh successful installation of Umbraco 4.0.3.
As soon as I open the page which has the Macto/Use Control, under Umbraco, it will fail, and following is the error I get using:
"?umbdebugshowtrace=true".
Aparently, there is conflict between the AjaxControlToolkit I am using and that which is used by Umbraco.
How I can resolve this problem ?
Note: This is my first project which will go-live under Umbraco at work.
Appreciate your help.
Tarek.
I will add more info about the above problem.
I tried to recompile my DLL (clinic User Controls) using the AjaxControlToolkit.dll (1.0.10920.32880) that comes with Umbraco. Compile was successful.
Then, I tried to run the User Control under Umbraco, this time, no error, but I am getting this client JavaScript Error:
And, the User Control is not working at all.
Appreciate your help.
Tarek.
I was able to resolve all the problems mentioned above, however, I have now another problem.
It seems that the PostBack event is not being detected inside the Page_Load Event inside the User Control. I did debug under Umbraco, and found out that Inside the Page_Load Event, the property "Page.IsPostBack" is alwasy false. This means, everytime the User Control in run in a Post-Back Event, it will be sent as a new request.
How I can resolve this problem ?
Tarek.
To solve your original problem you can probably just get away with using assemblyBinding in the web.config (http://msdn.microsoft.com/en-us/library/twy1dw1e.aspx).
As for your current problem, not sure.
Not only the "IsPostBack" event is always "false", also, the "TextChanged" event for the "TextBox" Server Control (inside the UC) is not being fired at all.
I created a code-behined for the Master Page I am using inside Umbraco, I did a test inside the "Page_Load" event of the Master Page, and I noticed that no mater what, the "IsPostBack" is alwasy "false".
I have tested my User Control from inside a traditional Web Project Application, and it is working successfully.
Please help.
Tarek.
Hi Tarek,
Can you post some code so we can see how you have implemented the updatepanel and textbox?
Can you get any event to fire? Like a button-click inside the updatepanel?
/Fredrik
Thank you Fredrik for the reply.
Note: I am using the Umbraco Runway Basic Document Types and MasterPages and other samples etc to do my test.
Let me define the problem so that it is clear:
1. The property "IsPostBack" is alwasy false.
2. The following events (which I tested) are not triggered on the server like "Button_Click" and "TextBox_TextChanged".
3. The PostBack Even is triggered. I mean, if you change the TextBox, it will cause a post-back, but the "TextChanged" event will not be executed.
The above problem will occur when:
1. When you have a User Control Macro which has Ajax and other complicated stuff like:
2. Only under Umbraco.
When I remove the complex user control and put a simple Macro User Control instead, everything works fine.
The same complex User Control works fine under a Traditional Web Application Project.
My guess is that using Ajax under Umbraco has caused some kind of conflict which is causing ASP.NET to misbehave.
Appreciated your help.
Here is the complete code of my Complex User Control:
Here is the CodeBehined:
Who, that is a complex control ;-)
I can't see any obvious errors. How about creating a new macro, and dissect the complex control and add part by part to the new control? That way, you'll know where it starts to break. Than perhaps we can narrow down what the problem seems to be.
/Fredrik
Fredrik,
Great I dea ... this is the only way. I will do that .... the only problem is that the Clinic Staff have committed a schedule to start the with new system.
By the way, this Clinic system was originally developed under DNN, and I decided to re-write it based on Ajax and User Controls to allow faster Data Entry. Under DNN, it was very sloooooow ... cause the user have to navigate among 5 screens to do simple updates. If I hope I can deploy it under Umbraco.
If I am unable to nail down the problem, I will have to use the Tranditional Web Application Project instead of Umbraco.
Tarek.
Well, using a traditional Web Application Project is a short-term solution. If you get it working under Umbraco it will save you a lot of time with future development.
Try taking baby-steps, examine where the problem occurs and keep us posted. We will try to assist you from there.
Fredrik,
The baby steps worked ! I can't be more happy. I know the source of the problem, but I am thinking how to resolve it.
Here is the culprit ASP Control:
If I delete the above <asp:LinkButton> Control, it workes, and I see the events are being executed and "IsPostBack" is working fine.
Also, if I keep this control and set the value of "PostBackUrl" to empty string, it works.
If I put any value for "PostBackUrl" the problem is back again. Even if I put a valid URL or even "#" !!!! This button will navigate from the Laboratory Entry Screen back to the Search Screen.
Do you think this is a bug in Umbraco ? Should I report it ?
Let me move now to finding a workaround:
Can you help me please ?
I have 2 main screens in this application. Each Screen is a Macro User Control.
Screen 1: Search Laboratory Requests. Here the user will use extermly flexible criteria to locate the Lab Request. When he clicks on an item in the ASP GridView, he must move to the Labroratory Request Entry Screen. Here is the code-behined for SelectedIndexChanged:
As you can see, I am hard-coding the URL of the second screen in the Traditional Web Application Project.
Screen 2: Laboratory Request Entry Screen. In this screen, the user will maintain the request entry and all its details. He can click on "Search Laboratory Request" to move back to the search screen, as you have seen in the link button above. But, I am hard-coding the URL.
Now, in Umbraco, what is the best way to implement this kind of navigation ?
Tarek.
To get dynamic links to a Node in Umbraco you can use:
umbraco.library.NiceUrl(int NodeId)
If the only purpose of that button is to link back to the search-page I would use an asp:HyperLink instead. That would give a cleaner html. But it shouldn't really matter.
Before you post it as a bug in Umbraco I would make certain what the button with postbackurl is acctually doing, using fiddler or something alike. It should try to post to a new page. I'm not really sure why it returns to the same page. That sounds fishy.
/Fredrik
The "postbackurl" of the ASP Link Button does not have any code-behind. If I remove the hard-coded URL, it will work.
I will try to implement the final solution tomorrow.
Tarek.
All is OK now.
Tarek.
This can be solved by disabling any control using PostBackUrl since they mess with postbacks in general in Umbraco
is working on a reply...