标题:如何在javascript中引用.net中写的类的方法
取消只看楼主
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
结帖率:100%
 问题点数:0 回复次数:6 
如何在javascript中引用.net中写的类的方法
大家帮帮忙:如何在javascript中引用.net中写的类的方法
搜索更多相关主题的帖子: javascript 
2008-08-20 11:14
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
有知道的吗,帮帮忙

http://www.
2008-08-20 17:02
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
我是这样做的,但没用
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pic.aspx.cs" Inherits="pic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.

<html xmlns="http://www. >
<head runat="server">
    <title>宜春</title>
     
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <script type="text/javascript"  src="js/flash.js"></script>
      
    </div>
    </form>
</body>
</html>


页面代码:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class pic : datacon
{
    protected void Page_Load(object sender, EventArgs e)
    {

        AjaxPro.Utility.RegisterTypeForAjax(typeof(pic));
    }
   
    [AjaxPro.AjaxMethod]
    public string GET_TYPE_ID(int id, string ids, string tables, string feildname)
    {
        //Open();
        string SQL = "select " + feildname + " from [" + tables+ "]  where " + ids + " = " + id+"";
        return Convert.ToString(parameter_sql.ExecuteScalar(datacon.strcnn, CommandType.Text, SQL, null));
        //SqlCommand cmd = new SqlCommand(SQL, conn);
        //string va = cmd.ExecuteScalar().ToString();
       // return va;
    }
}


js文件


var pic_width=580; //图片宽度
var pic_height=265; //图片高度
var button_pos=4; //按扭位置 1左 2右 3上 4下
var stop_time=3000; //图片停留时间(1000为1秒钟)
var show_text=0; //是否显示文字标签 1显示 0不显示
var txtcolor="000000"; //文字色
var bgcolor="DDDDDD"; //背景色
var imag=new Array();
var link=new Array();
var text=new Array();
imag[1]=pic.GET_TYPE_ID(1,"typeid","pic","img");
link[1]="http://www.
text[1]="标题 1";
imag[2]=pic.GET_TYPE_ID(2,"typeid","pic","img");
link[2]="http://www.
text[2]="标题 2";
imag[3]=pic.GET_TYPE_ID(3,"typeid","pic","img");
link[3]="http://www.
text[3]="标题 3";
imag[4]=pic.GET_TYPE_ID(4,"typeid","pic","img");
link[4]="http://www.
text[4]="标题 4";
imag[5]=pic.GET_TYPE_ID(5,"typeid","pic","img");
link[2]="http://www.
text[5]="标题 5";
//可编辑内容结束
var swf_height=show_text==1?pic_height+20:pic_height;
var pics="", links="", texts="";
for(var i=1; i<imag.length; i++){
    pics=pics+("|"+imag[i]);
    links=links+("|"+link[i]);
    texts=texts+("|"+text[i]);
}
pics=pics.substring(1);
links=links.substring(1);
texts=texts.substring(1);
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.,0,0,0" width="'+ pic_width +'" height="'+ swf_height +'">');
document.write('<param name="movie" value="js/focus.swf">');
document.write('<param name="quality" value="high"><param name="wmode" value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'">');
document.write('<embed src="js/focus.swf" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'" quality="high" width="'+ pic_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www. />');
document.write('</object>');

http://www.
2008-08-21 14:51
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
帮忙看看这句哪里有问题:
imag[1]=pic.GET_TYPE_ID(1,"typeid","pic","img");
link[1]="http://www.
text[1]="标题 1";
imag[2]=pic.GET_TYPE_ID(2,"typeid","pic","img");
link[2]="http://www.
text[2]="标题 2";
imag[3]=pic.GET_TYPE_ID(3,"typeid","pic","img");
link[3]="http://www.
text[3]="标题 3";
imag[4]=pic.GET_TYPE_ID(4,"typeid","pic","img");
link[4]="http://www.
text[4]="标题 4";
imag[5]=pic.GET_TYPE_ID(5,"typeid","pic","img");
link[2]="http://www.
text[5]="标题 5";

http://www.
2008-08-21 14:52
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
我试了,没用,我用的是ajax调用类的方法

http://www.
2008-08-22 15:59
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
不是呀兄弟,我要的是在javascript中调用,如果要在.net页中调用直接<%=ResourceBase.GetUIText("参数")%>
就可

http://www.
2008-08-25 17:53
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
问题解决了:pic.GET_TYPE_ID(1,"typeid","pic","img").value

http://www.
2008-08-27 10:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-229142-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.208913 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved