我正在開發一個組項目,並試圖找出ASP.net(很少有人在我的組中知道它,包括我)。我的工作是創建一些文本框和按鈕,以便當點擊該按鈕時,文本框中的文本將被處理併發布,如果它有< = 140個字符。發送輸入文本數據到ASP端的HTML按鈕
我試着編寫一些jQuery來檢查文本框中的文本,然後將它發送到服務器進行處理。服務器將其保存到數據庫,並將其發佈到頁面,如果它不超過140個字符(將再次檢查)。
不幸的是,我遇到了this錯誤。我試圖聯繫我的團隊成員,但他們忙於處理其他問題。這裏是我的代碼:
Feed.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Feed.aspx.cs" Inherits="Feed_Feed" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<!-- This is here for test purpose -->
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(
function()
{
$('#TweetButton').click(
function()
{
// get the text from the TweetBox
var status = $('#TweetBox').val();
// if it is 140 characters or less
if (status.length <= 140)
{
var data = JSON.stringify(status);
// send to the server page
$.ajax({
url: '/Feed.aspx.cs',
type: 'POST',
dataType: 'json',
data: data,
success: function(myStatus)
{
$('#MyStatus').html(myStatus);
}
});
}
else
{
alert("Tweet should contain no more than 140 characters");
}
});
});
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<h1>User Feed</h1>
<p>
<input id="TweetBox" type="text" /><input id="TweetButton" type="button" value="button" />
</p>
<div id="MyStatus"></div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="LeftContent" Runat="Server">
</asp:Content>
Feed.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Feed_Feed : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
C#的文件實際上是空的,因爲我不知道如何處理的數據是張貼到頁面(應該在Page_Load
?)我不知道該怎麼辦...
到目前爲止,這甚至不是您的代碼導致的問題,這是您的web.config配置不愉快。你有沒有驗證你的所有連接信息?根據[這個答案](http://stackoverflow.com/a/16988949/3499931),你需要設置'Copy Local = true'。 – Trasiva
我在哪裏寫?你(他們)是否在談論這樣做:https://msdn.microsoft.com/en-us/library/t1zz5y8c(v=vs.90).aspx? –
爲什麼有人投票結束這個問題?這是一個嚴重的問題,因爲與之相關的答案根本不明確!更糟糕的是,當我看着微軟網站時,他們的指示根本無法遵循。 –