PDA

View Full Version : [CLOSED] AjaxMethod issue



Rod
Oct 06, 2008, 4:45 AM
Hello.
I tried to implement the authentication sample, but I can't get it to work, and I dn't have any clue why.
Here is my code

Authentification.ascx


<ext:ScriptManager ID="ScriptManager1" runat="server" />

<ext:Window ID="LoginWindow" runat="server" Closable="false" Resizable="false" Height="150"
Icon="Lock" Title="Authentification" Draggable="false" Width="350" Modal="true"
BodyStyle="padding:5px;">
<Content>
<ext:FormLayout ID="FormLayout1" runat="server">
<ext:Anchor>
<ext:TextField ID="txtUsername" runat="server" FieldLabel="Identifiant" AllowBlank="false"
BlankText="Votre identifiant est requis." EmptyText="monadresse@mail.com" Width="200px" />
</ext:Anchor>
<ext:Anchor>
<ext:TextField ID="txtPassword" runat="server" InputType="Password" FieldLabel="Mot de passe"
AllowBlank="false" BlankText="Votre mot de passe est requis." EmptyText="Mot de passe"
Width="200px" />
</ext:Anchor>
<ext:Anchor>
<ext:Label ID="lblMessage" runat="server" />
</ext:Anchor>
</ext:FormLayout>
</Content>
<Buttons>
<ext:Button ID="btnLogin" runat="server" Text="Connection" Icon="Accept">
<Listeners>
<Click Handler="if(!#{txtUsername}.validate() || !#{txtPassword}.validate()) {
Ext.Msg.alert('Erreur','L\'identifiant et le mot de passe sont requis');
// return false to prevent the btnLogin_Click Ajax Click event from firing.
return false;
}" />
</Listeners>
<AjaxEvents>
<Click OnEvent="btnLogin_Click">
<EventMask ShowMask="true" Msg="Vérification..." MinDelay="500" Target="CustomTarget"
CustomTarget="#{LoginWindow}" />
</Click>
</AjaxEvents>
</ext:Button>
</Buttons>
</ext:Window>




Authentification.ascx.vb


Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
lblMessage.SetText("Identifiant ou mot de passe incorrect")
End Sub


Now the problem is that it doesn't work that way, as it throw a "BADRESPONSE, syntax error" window. Any help would be appreciated.
Also, the error windows displays just fine with ff, but the 4 supposedly hidden fields are displayed as inputs with ie. Hiding them would be really appreciated :p


Edit : I meant AjaxEvents issue, sry -_-

geoffrey.mcgill
Oct 06, 2008, 5:40 AM
Hi Rod,

Please add the following node to your Web.config file to enable AjaxEvents.

Example


<system.web>
 <httpModules>
  <add name="AjaxRequestModule"
   type="Coolite.Ext.Web.AjaxRequestModule, Coolite.Ext.Web" />
 </httpModules>
</system.web>
More information is available within the README.txt file which is included in all the manual installation packages and gets installed to your "Start" menu if you run the .exe installer.

I'll post the full contents of the relavent README.txt section below.


Version: 0.6.0
Last Updated: 2008-10-02</p>


--------------------------------------------------------------------------
                  ENABLE AJAXEVENTS IN WEB.CONFIG
--------------------------------------------------------------------------</p>


The release of Version 0.6.0 has introduced a new feature called
"AjaxEvents". The AjaxEvents enable an Ajax postback to be attached to
any event.</p>


The AjaxEvents perform a full PostBack, but does this threw the use of Ajax.
The Page will go threw it's entire page life-cycle as a classic postback,
although will only return JavaScript in the response. The JavaScript is
then executed on the client on successful round trip. </p>


No HTML is returned from the AjaxEvent. Currently, a new control can not
be created during an AjaxEvent. All controls that require updating on the
client must be available in the Page .Controls Collection before the
AjaxEvent executes. </p>


To enable the AjaxEvents functionality you must add the following
"AjaxRequestModule" node to your projects Web.config file.</p>


Example</p>


<system.web>
 <httpModules>
  <add name="AjaxRequestModule"
   type="Coolite.Ext.Web.AjaxRequestModule, Coolite.Ext.Web" />
 </httpModules>
</system.web></p>


Once the "AjaxRequestModule" has been added to the web.config, you can
trigger an AjaxEvent by adding to the <AjaxEvents> property of each
Coolite Toolkit control.</p>


The following demonstrates setting the <Click> AjaxEvent on an
<{0}:Button> and then calling .Show() on an <{0}:Window> control. </p>


Example</p>


<script runat="server">
    protected void Button1_Click(object sender, AjaxEventArgs e)
    {
        this.Window1.Show();
    }
</script></p>


<{0}:Button ID="Button1" runat="server" Text="Show Window">
    <AjaxEvents>
        <Click OnEvent="Button1_Click" />
    </AjaxEvents>
</{0}:Button>

Hope this helps.
</p>

Rod
Oct 06, 2008, 5:49 AM
I'm sorry I HAVE read the read me, and I HAVE read that I need to add this node, but i'm just too stupid to remember it more than 10 min :/

Working fine now, sry again :(

geoffrey.mcgill
Oct 06, 2008, 5:55 AM
No problem. I'm happy to help.

I'm hoping to have the controls automatically add the reference to the AjaxEvents Module within the next release. We had to leave it out of the v0.6 release because of some possible Visual Studio crashing issues that may have been caused by us trying to dynamically write to the web.config file.

Rod
Oct 06, 2008, 6:23 AM
That would be nice idd, as i'm afraid some ppl will also forget this point :/