各位高手:
js中的数据类型为弱类型,应该是没有数据类型转换一说,不知ajaxpro有没提供这样的转换类,
问题是这样的:
修改一条用户信息
public class GratisUser
{
private int area_id; public int Area_id
{
get { return area_id; }
set { area_id = value; }
}
}
//实列化用户对像
[AjaxPro.AjaxMethod]
public GratisUser GetGsUser()
{
return new GratisUser();
} //修改店铺信息
[AjaxPro.AjaxMethod]
public int ModefiyShop(GratisUser gsUs)
{
return GratisUserManager.ModifyGratisUserByUser(gsUs);
}对应页面js代码 var gsUs = UpdateIntroduce.GetGsUser().value;
gsUs.Area_id = document.getElementById("areaid").value;
if (UpdateIntroduce.ModefiyShop(gsUs).value !=0) {
alert("信息已成功修改");
} else {
alert("信息修改失败");
}已上代码持行后对像GratisUser()为空
gsUs.Area_id = document.getElementById("areaid").value;
我想应该是gsUs.Area_id类型为int型的,而document.getElementById("areaid").value是string型的,
数据类型不匹配导致错误我菜鸟,望高手指教,非常感谢
js中的数据类型为弱类型,应该是没有数据类型转换一说,不知ajaxpro有没提供这样的转换类,
问题是这样的:
修改一条用户信息
public class GratisUser
{
private int area_id; public int Area_id
{
get { return area_id; }
set { area_id = value; }
}
}
//实列化用户对像
[AjaxPro.AjaxMethod]
public GratisUser GetGsUser()
{
return new GratisUser();
} //修改店铺信息
[AjaxPro.AjaxMethod]
public int ModefiyShop(GratisUser gsUs)
{
return GratisUserManager.ModifyGratisUserByUser(gsUs);
}对应页面js代码 var gsUs = UpdateIntroduce.GetGsUser().value;
gsUs.Area_id = document.getElementById("areaid").value;
if (UpdateIntroduce.ModefiyShop(gsUs).value !=0) {
alert("信息已成功修改");
} else {
alert("信息修改失败");
}已上代码持行后对像GratisUser()为空
gsUs.Area_id = document.getElementById("areaid").value;
我想应该是gsUs.Area_id类型为int型的,而document.getElementById("areaid").value是string型的,
数据类型不匹配导致错误我菜鸟,望高手指教,非常感谢
解决方案 »
- Google的首页太有创意了,有谁知道这素Javascript做的么,大家知道啥都进来讨论讨论吧~
- 系统设计文档如何写,提供模版最好(网址,网站)
- 帮我看下这样的JS(function())();
- 在线等!急!dropdownlist问题?
- 求救!!!! asp.net(C#)数据储存结构
- 用户控件 属性传递问题~搜索了 N 多帖子,BAIDU 了很多文章.还是没成功
- 求一段系统自动生成订单号的代码。
- 类似于froogle这样的网站让你做要多少M?
- 关于IValidator
- 呵呵 这就是现在程序员的发展状况?
- 一个数字判断的问题,如果大于某值就弹出提示框
- 用代码把SQL2000导入Excel2003
public GratisUser GetGsUser()
{
return new GratisUser().Area_id;
}
这样的结果肯定不是对的,不知各位使用ajaxpro的高手们是如何解决的,要是那位好心高手能给个带分页,数据绑定等等....功能的原码,那真是感激不已
首先我不可能会没注册,只要对像的字段是string型的都能在js中正确赋值,如下 public class Student
{
private int age;
public int Age
{
get{return this.age;}
set{this.age= value;}
}
private string name;
public string Name
{
get{return this.name;}
set{this.name= value;}
}
}
//服务端添加GetStudent方法:
[AjaxPro.AjaxMethod]
public Student GetStudent()
{
return new Student();
}
//修改店铺信息
[AjaxPro.AjaxMethod]
public int ModefiyShop(Student stu)
{
return GratisUserManager.ModifyGratisUserByUser(stu);
}<input type="text" id="age" />
<input type="text" id="name" />
function getStudent()
{
var stu = GratisUserManager.GetStudent().value ;
stu.Name = document.getElementById("name").value; //正确运行
stu.Age = document.getElementById("age").value; //程序会在这出错,stu.Age是int型
if (UpdateIntroduce.ModefiyShop(stu).value !=0) {
alert("信息已成功修改");
} else {
alert("信息修改失败");
} }使用ajaxpro的高手们,请指教了,如果要进行数据类型转换,那又要怎么办了
public class Student
{
private int age;
public int Age
{
get{return this.age;}
set{this.age= value;}
}
private string name;
public string Name
{
get{return this.name;}
set{this.name= value;}
}
}
,我想主要问题应该不是出在这
stu.Age = document.getElementById("age").value; //程序会在这出错,stu.Age是int型//将上面改为
stu.Age = parseInt(document.getElementById("age").value);
//string型就已转换为int
parseFloat()是转换double
那时间类型了????,如何转换时间类型
下面是(痞子(ialvin.cn)) 提供的方法var s = "2005-08-12 12:23:44";var mr = /^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/.exec(s);
if (mr) {
var d = new Date(parseInt(mr[1], 10),
parseInt(mr[2], 10)-1,
parseInt(mr[3], 10),
parseInt(mr[4], 10),
parseInt(mr[5], 10),
parseInt(mr[6], 10));
objdw.SetItem(1, 1, d.getVarDate());
} else {
alert("格式不正确!");
}