zoller
Member
Recently I started messing with page methods and after a lot of research (google) I think I've found a way to implement this which requires the least amount of code.
Code Behind
Javascript
So, regarding the javascript PageMethods function - I stumbled across this on a developers blog and am wondering where can we find out what other javascript functions are available to us? for example I know there is a javascript function to run validation but my only way to find out is if someone else posts it.
Is there a reference with all the javascript functions provided by .NET ?
I only want to educate myself - so if anyone could point me in the right direction it would be greatly appreciated. Thanks
P.S. I'm not entirely sure if this is the right topic to post in - feel free to move it
Code Behind
VB.NET:
[COLOR=#0000ff]Protected[/COLOR] [COLOR=#0000ff]Shared[/COLOR] _Value [COLOR=#0000ff]As[/COLOR] [COLOR=#6f002f]String[/COLOR]
[COLOR=#0000ff]Protected[/COLOR] [COLOR=#0000ff]Shared[/COLOR] [COLOR=#0000ff]Property[/COLOR] Value() [COLOR=#0000ff]As[/COLOR] [COLOR=#6f002f]String[/COLOR]
[COLOR=#0000ff]Get[/COLOR]
[COLOR=#0000ff]Return[/COLOR] _Value
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Get[/COLOR]
[COLOR=#0000ff]Set[/COLOR]
_Value = value
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Set[/COLOR]
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Property[/COLOR]
<WebMethod()> _
[COLOR=#0000ff]Public[/COLOR] [COLOR=#0000ff]Shared[/COLOR] [COLOR=#0000ff]Function[/COLOR] GetValue() [COLOR=#0000ff]As[/COLOR] [COLOR=#6f002f]String[/COLOR]
[COLOR=#0000ff]If[/COLOR] [COLOR=#8515ea]Not[/COLOR] [COLOR=#6f002f]String[/COLOR].IsNullOrEmpty(_Value) [COLOR=#0000ff]Then[/COLOR]
[COLOR=#0000ff]Return[/COLOR] _Value
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If[/COLOR]
[COLOR=#0000ff]Return[/COLOR] "Value is empty!"
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Function[/COLOR]
<WebMethod()> _
[COLOR=#0000ff]Public[/COLOR] [COLOR=#0000ff]Shared[/COLOR] [COLOR=#0000ff]Sub[/COLOR] SetValue([COLOR=#0000ff]ByVal[/COLOR] value [COLOR=#0000ff]As[/COLOR] [COLOR=#6f002f]String[/COLOR])
_Value = value
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub[/COLOR]
Javascript
VB.NET:
[COLOR=#008000]// This is only required when using cookieless session state[/COLOR]
PageMethods.set_path([COLOR=#a0522d]'PageMethods.aspx'[/COLOR]);
[COLOR=#008000]// Get Method[/COLOR]
PageMethods.GetValue([COLOR=#0000ff]function[/COLOR] (response) {
alert(response);
}, onFail);
[COLOR=#008000]// Set Method[/COLOR]
PageMethods.SetValue([COLOR=#a0522d]'value here'[/COLOR], [COLOR=#0000ff]null[/COLOR], onFail);
[COLOR=#0000ff]function[/COLOR] onFail() {
alert([COLOR=#a0522d]'Failed to call web method.'[/COLOR]);
}
So, regarding the javascript PageMethods function - I stumbled across this on a developers blog and am wondering where can we find out what other javascript functions are available to us? for example I know there is a javascript function to run validation but my only way to find out is if someone else posts it.
Is there a reference with all the javascript functions provided by .NET ?
I only want to educate myself - so if anyone could point me in the right direction it would be greatly appreciated. Thanks
P.S. I'm not entirely sure if this is the right topic to post in - feel free to move it
Last edited: