PDA

View Full Version : AjaxMethod attributes Type and ShowMask



alco
Nov 19, 2009, 9:28 AM
...or it seems like they don't. Anyway, the thing is, I want to set the Type to AjaxEventType.Load so it does not take in the view state and form elements.

[AjaxMethod(ShowMask=true,Msg="Saving...",Type=AjaxEventType.Load)]


But, after the request is processed, Coolite tries to "unmask" and fails at this line



reconfigure:function(store,colModel){if(this.loadM ask){this.loadMask.destroy()


Inspecting the loadMask object show it only has one boolean property, showMask.

Vladimir
Nov 19, 2009, 9:46 AM
Hi,

Did you set ShowMask="true" during AjaxEvent/AjaxMethod? Or it was set during initial PageLoad?
Please provide simple example

alco
Nov 19, 2009, 10:01 AM
JS code


var InstructionEditorSaveButton_Click = function() {
Coolite.AjaxMethods.<%= this.ClientID %>.SaveInstruction(id, content, {
success: function(result) {
if (result.serviceResponse.success) {
Ext.Msg.alert('Saved', result.serviceResponse.message);
<%= window.ClientID %>.hide();
}
else ShowError('Save failed', result.serviceResponse.message);
},
failure: function(errorMessage) {
ShowError('Save failed', errorMessage);
}
});
}


CS code


[AjaxMethod(ShowMask=true,Msg="Saving...",Type=AjaxEventType.Load)]
public void SaveInstruction(int id, string content) {
try
{
if (string.IsNullOrEmpty(content))
{
throw new Exception("Please enter content.");
}
PortalContentPage.UpdateContentPage(id, content);
Coolite.Ext.Web.ScriptManager.AjaxSuccess = true;
Coolite.Ext.Web.ScriptManager.ServiceResponse = new { success = true, message = "Saved." };
}
catch (Exception ex)
{
Coolite.Ext.Web.ScriptManager.AjaxSuccess = false;
Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = ex.Message;
}
}

alco
Nov 19, 2009, 10:03 AM
I tried dropping the ShowMask=true,Msg="Saving...", attributes, but then I keep getting "transaction aborted"

Vladimir
Nov 19, 2009, 10:04 AM
Hi,

What is 'UpdateContentPage' ? Exception occurs in the 'reconfigure' method but I don't see that you call it

alco
Nov 19, 2009, 10:15 AM
UpdateContentPage wraps a DB update.

I don't call reconfigure. It's probably getting called by the ajax response handler or something.

Vladimir
Nov 19, 2009, 10:23 AM
Hi,

Did you add/insert/remove columns during AjaxMethod request? Please provide test example otherwise we can guess only

alco
Nov 19, 2009, 10:33 AM
ASCX code--------------------------------


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Instructions.ascx.cs" Inherits="Admin.Controls_Instructions" %>
<%@ Register Namespace="Coolite.Ext.Web" Assembly="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>


<script type="text/javascript" >
var InstructionEditorSaveButton_Click = function() {
var content = "";

var oEditor = FCKeditorAPI.GetInstance('<%= InstructionEditorContentHtmlEditor.ClientID %>');
if (oEditor) content = oEditor.GetData();

content = escape( content );

if ( Ext.isEmpty(content) ) {
Ext.Msg.alert('Invalid entry', 'Please enter content.');
}
// If Content Fields are not blank, begin saving the page to the database
else {
// Get the id of the page that will be updated
var record = <%= InstructionsManagerGridPanel.ClientID %>.getSelectionModel().getSelected();
var id = 0;
id = record.data.Id;
record.set('Content', content);

Coolite.AjaxMethods.<%= this.ClientID %>.SaveInstruction(id, content, {
success: function(result) {
if (result.serviceResponse.success) {
record.commit();
Ext.Msg.alert('Saved', result.serviceResponse.message);
<%= winInstructionsManager.ClientID %>.hide();
}
else HRCA_ShowError('Save failed', result.serviceResponse.message);
},
failure: function(errorMessage) {
HRCA_ShowError('Save failed', errorMessage);
}
});
}
}

var InstructionEditorCloseButton_Click = function() {
<%= winInstructionEditor.ClientID %>.hide();
}

</script>



<ext:Window
ID="winInstructionEditor"
runat="server"
Title="Page Editor"
Show&#111;nload="false"
Height="600"
Width="800"
Modal="True"
AutoRender="false"
Maximizable="true"
>
<Listeners>
<AfterLayout Handler="autoSizeFCKeditor( #{InstructionEditorContentHtmlEditor}.id, #{panelInstructionEditorContentHtmlEditor}.id )" />
</Listeners>
<Body>
<ext:FitLayout ID="InstructionEditorFitLayout" runat="server">
<ext:Panel ID="panelInstructionEditorContentHtmlEditor" runat="server" >
<Body>

<FCKeditorV2:FCKeditor ID="InstructionEditorContentHtmlEditor" runat="server" BasePath="~\fckeditor\" ></FCKeditorV2:FCKeditor>

</Body>
</ext:Panel>
</ext:FitLayout>
</Body>
<Buttons>
<ext:Button ID="InstructionEditorSaveButton" runat="server" Text="Save">
<Listeners>
<Click Fn="InstructionEditorSaveButton_Click" />
</Listeners>
</ext:Button>
<ext:Button ID="InstructionEditorCloseButton" runat="server" Text="Close">
<Listeners>
<Click Fn="InstructionEditorCloseButton_Click" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Window>



The only method that matters in the ASCX.CS file is the SaveInstruction, w/c I already provided.

Vladimir
Nov 19, 2009, 12:06 PM
Hi,

That user control is not related with that error because 'reconfigure' is GridPanel function. Please demonstrate GridPanel code (code-behind and markup)