2011-06-17 79 views
0

谢谢大家的帮助!到目前为止,在这个网站上有一些真正有用的答案,所以我希望再多一次。.aspx文件帮助

我想创建也正是这一点,但我仍然有问题

http://www.webonweboff.com/widgets/ajax/ajax_linked_selection.aspx

我抄HTML和JavaScript的词字,并保存该文件作为index.html的(但显然与开闭html和body标签)

的文件我已经叫ajaxServer.aspx.cs具有下面的代码:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Text; 

public partial class _Default : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     Response.ContentType = "text/javascript"; 
     string id = Request.QueryString.Get("id"); 
     string action = Request.QueryString.Get("action"); 
     StringBuilder returnString = new StringBuilder(); 

     /* 
      Retrieve the data based on values "id" and "action" 
      and build a response string in this format: 
       [{text:"...", 
     * 
     * value:"...",selected:false}, 
       {text...}] 
      No final ";" is necessary 

      For example: 
     returnString.Append("[{text:\"California\",value:\"CA\",selected:false}," + 
          "{text:\"OH\",value:\"Ohio\",selected:false}," + 
          "{text:\"NY\",value:\"New York\",selected:true}]"); 

     */ 

     Response.Write(returnString.ToString()); 
    } 
} 

我已经叫ajaxServer.aspx文件中有如下代码:

<%@ Page Language="C#" AutoEventWireup="true" 
    CodeFile="ajaxServer.aspx.cs" Inherits="_Default" %> 

其他(.js文件)我已经下载并保存的文件。当我运行.html文件时出现以下错误:

错误提取数据!

网址:ajaxServer.asp

方法:GET

PARAMS:动作=状态,文化= EN-US

的readyState:4

状态:403

头:服务器:ASP.NET Development Server/10.0.0.0 日期:Sun,19 Jun 2011 20:39:55 GMT X-AspNet-Version:4.0.30319 Cache-Control:private Content-Type:text/html; charset = utf-8 内容长度:2126 连接:关闭

- >任何线索任何人?再一次感谢您提前提供的所有帮助!

+0

回答后不要删除问题。它可能会帮助其他人在未来 – citronas

回答

0

我相信你想改变你的ajaxServer.aspx文件,使Inherits =“_ Default”而不是Inherits =“widgets_ajax_ajaxServer”。

+0

您好 - 感谢您的帮助。那个错误已经消失了,我现在又得到了另一个。它说“无法找到类型或命名空间'StringBuilder'(你是否缺少使用侦探或程序集引用?) – Joe

+0

使用System.Text添加;作为使用声明。 – adt

1

将您的类从_Default重命名为widgets_ajax_ajaxServer。

+0

太糟糕了,只能有一个检查答案。你的答案是相反的。 – Seneca

0

“(你错过了一个使用侦探或装配参考吗?)”意思就是它说什么。

StringBuilder位于System.Text命名空间中。

所以你需要一个

使用System.Text;

声明在类的顶部。

+0

谢谢你 - 让改变和错误消失。当我实际上打开index.html时,我的第二个框中现在没有选项 - 与我从中获取代码的链接中的示例不同。任何想法在这一个?再次感谢! – Joe