将静态类连接到非静态类 [英] Connect static class to nonstatic
问题描述
< script type = text / javascript> ;
function ShowCurrentTime(){
var base64 = $(' #colors_sketch')[ 0 ]。toDataURL() ;
$ .ajax({
type: POST ,
url: Dms_BOM.aspx / GetCurrentTime,
data:< span class =code-string>' {name:' + base64 + ' }',
contentType: application / json; charset = utf-8,
dataType: json,
成功:OnSuccess,
失败: function (响应){
alert(response.d);
}
});
}
function OnSuccess(响应){
alert(response.d);
}
< / script>
[System.Web。 Services.WebMethod]
public static string GetCurrentTime( string name)
{
FILLHOD(name);
return Base64代码: + name;
}
受保护 void FILLHOD( string name)
{
}
i使用ajax函数传递数据到代码后面,从静态方法调用非静态函数来插入数据到数据库但是得到一些错误:需要对象引用对于非静态字段,方法,任何想法如何处理这个问题,是否可能将ajax函数连接到c#中的非静态函数?
什么我试过了:
没什么。
(' #colors_sketch')[ 0 ]。toDataURL();
.ajax({
type: POST ,
url: Dms_BOM.aspx / GetCurrentTime,
data: ' {name:' + base64 + ' }',
contentType: application / json; charset = utf-8,
dataType: json,
成功:OnSuccess,
失败: function (响应){
alert(response.d);
}
});
}
function OnSuccess(响应){
alert(response.d);
}
< / script>
[System.Web.Services.WebMethod]
public static string GetCurrentTime( string name)
{
FILLHOD(name);
return Base64代码: + name;
}
protected void FILLHOD( string name)
{
}
i使用ajax函数传递数据到代码后面,来自静态方法调用一个非静态函数来插入数据到数据库但是得到一些错误:非静态字段,方法,任何想法如何处理这个问题都需要对象引用,并且可能将ajax函数连接到c#中的非静态函数?
我尝试了什么:
没什么。
使FILLHOD也是静态的。
protected 静态 void FILLHOD( string 名)
<script type="text/javascript">
function ShowCurrentTime() {
var base64 = $('#colors_sketch')[0].toDataURL();
$.ajax({
type: "POST",
url: "Dms_BOM.aspx/GetCurrentTime",
data: '{name: "' + base64 + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
</script>
[System.Web.Services.WebMethod]
public static string GetCurrentTime(string name)
{
FILLHOD(name);
return "Base64 code :" + name ;
}
protected void FILLHOD(string name)
{
}
i use ajax function pass data to code behind,from static method call a non static function for insert data to database but getting some error :An object reference is required for the nonstatic field, method,any ideas how to deal with this issue,and is that possible connect ajax function to non static function in c#?
What I have tried:
Nothing.
('#colors_sketch')[0].toDataURL();
.ajax({ type: "POST", url: "Dms_BOM.aspx/GetCurrentTime", data: '{name: "' + base64 + '" }', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { alert(response.d); } }); } function OnSuccess(response) { alert(response.d); } </script>
[System.Web.Services.WebMethod] public static string GetCurrentTime(string name) { FILLHOD(name); return "Base64 code :" + name ; }
protected void FILLHOD(string name) { }
i use ajax function pass data to code behind,from static method call a non static function for insert data to database but getting some error :An object reference is required for the nonstatic field, method,any ideas how to deal with this issue,and is that possible connect ajax function to non static function in c#?
What I have tried:
Nothing.
Make FILLHOD static as well.
protected static void FILLHOD(string name)
这篇关于将静态类连接到非静态类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!