Flash AS2.0與ASP.Net(C#)之間的資料互動

來源:互聯網
上載者:User

flash端的AS
var SendVars:LoadVars=new LoadVars();
var ReceiveVars:LoadVars=new LoadVars();
ReceiveVars.onLoad=function(Success:Boolean):Void{
        if(Success)
        {
            if(ReceiveVars.ok!=undefined)
            {
            intext.text="";
            intxt.text="";
            status_lbl.text = "<b>成功發表</b>";
            }
            else
            getURL("javascript:alert('有錯誤了啊');");
            }
        else
        {
            getURL("javascript:alert('發表失敗!');");
        }
}

submit_btn.clickHandler = function() {
    callSave();
}

function callSave()
{
    var url="accesslink.aspx";   
    SendVars.nn=escape(intext.text);
    SendVars.ct=escape(intxt.text);
    SendVars.op="add";
    SendVars.sendAndLoad(url,ReceiveVars,"POST");
    wait.gotoAndPlay(1);   
}

C#端的接受:
OleDbConnection conn = new OleDbConnection(ConfigurationManager.AppSettings["MyJetConn"]);
        string SQL = "INSERT INTO message (nicename,content) VALUES (?,?)";
        OleDbCommand cmd = new OleDbCommand(SQL, conn);
        cmd.Parameters.Add(new OleDbParameter("@nicename", OleDbType.VarChar, 10));
        cmd.Parameters["@nicename"].Value =Server.UrlDecode(Request.Form["nn"].ToString());
        cmd.Parameters.Add(new OleDbParameter("@content", OleDbType.VarChar, 50));
        cmd.Parameters["@content"].Value = Server.UrlDecode(Request.Form["ct"].ToString());
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        Response.Write("修改成功!");

web的配置,這裡要加的不然亂碼,FLASH裡面是預設的UTF-8
<system.web>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.