May 06, 2010, 4:20 PM
Changing value of hidden field with ajax event.
Hi
I am new to Coolite and having some issues. The project I am working on is an already built project with ASP.NET 3.5 and Coolite 0.8.1.2802. Any help or guidance is appreciated.
I don't know why [ code] [ / code] block is not working properly - at least in preview. Sorry for the inconvenience.
The problem: I am trying to change text / value of ext:hidden
Code at ASPX
Code at ASPX.cs
What I tried
1. I tried to include view state by adding this to web.config
by changing ASPX markup
and also by changing the ajax method attribute to
but none of these were able to change the value of HDLoadID
2. I also tried different approach by calling the method as an ajax method
ASPX.cs code
ASPX code
and I also tried variations with this by supplying ID as done in the following example
https://examples1.ext.net/#/Events/AjaxMethods/ID_Mode/
but I kept getting javascript exceptions like "Object doesn't support this property or method."
I opened the DOM in Firefox + firebug and found that Coolite.AjaxMethods is always empty.
Please guide me what should I do in order to get the generated guid on the client and pass it to the javascript function.
Thanks and Regards
Amar Chaudhary
I am new to Coolite and having some issues. The project I am working on is an already built project with ASP.NET 3.5 and Coolite 0.8.1.2802. Any help or guidance is appreciated.
I don't know why [ code] [ / code] block is not working properly - at least in preview. Sorry for the inconvenience.
The problem: I am trying to change text / value of ext:hidden
Code at ASPX
<ext:Hidden ID="HDLoadId" runat="server" />
<ext:ToolbarButton runat="server" ID="btnInsertLoad" Text="Create Load and Next" Icon="Disk">
<Listeners>
<Click Handler="return isNewLoadValid(); " />
</Listeners>
<AjaxEvents>
<Click OnEvent="SaveLoad" Success="CreateNewLoadCallBack();">
<EventMask ShowMask="true" Msg="Updating....." />
</Click>
</AjaxEvents>
</ext:ToolbarButton>
Javascript functions
isNewLoadValid - checks the validity of the form - working ok.
CreateNewLoadCallBack - performs some task with HDLoadID value - performing ok if the value is supplied to HDLoadID
Code at ASPX.cs
public void SaveLoad(object sender, AjaxEventArgs e)
{
try
{
if (HDLoadId.Text.Length == 0)
{
Guid id = NewLoadControl1.AddNewLoad();
HDLoadId.Text = id.ToString();
}
}
catch (Exception ex)
{
.
.
.
}
}
What I tried
1. I tried to include view state by adding this to web.config
ajaxViewStateMode="Include"
by changing ASPX markup
<AjaxEvents>
<Click OnEvent="SaveLoad" Success="CreateNewLoadCallBack(result);" ViewStateMode="Include">
<EventMask ShowMask="true" Msg="Updating....." />
</Click>
</AjaxEvents>
and also by changing the ajax method attribute to
[AjaxMethod(ViewStateMode = ViewStateMode.Include)]
but none of these were able to change the value of HDLoadID
2. I also tried different approach by calling the method as an ajax method
ASPX.cs code
[AjaxMethod]
public void SaveLoad(object config, object obj)
{
try
{
if (HDLoadId.Text.Length == 0)
{
Guid id = NewLoadControl1.AddNewLoad();
HDLoadId.Text = id.ToString();
}
}
catch (Exception ex)
{
.
.
.
}
}
ASPX code
<ext:ToolbarButton runat="server" ID="btnInsertLoad" Text="Create Load and Next" Icon="Disk">
<Listeners>
<Click Handler="if(isNewLoadValid()){
alert('in');
Coolite.AjaxMethods.SaveLoad( {success:SaveValue },{eventMask : {showMask: true}});
alert('Saved');}"
/>
</Listeners>
</ext:ToolbarButton>
Javascript :
var SaveValue = function (result) {
#{HDLoadId}.setValue(result);
CreateNewLoadCallBack();
}
and I also tried variations with this by supplying ID as done in the following example
https://examples1.ext.net/#/Events/AjaxMethods/ID_Mode/
but I kept getting javascript exceptions like "Object doesn't support this property or method."
I opened the DOM in Firefox + firebug and found that Coolite.AjaxMethods is always empty.
Please guide me what should I do in order to get the generated guid on the client and pass it to the javascript function.
Thanks and Regards
Amar Chaudhary