2011-06-17 78 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