开发者

jeditable in an ASP.NET web form

Can someone explain to me how you would use jeditable with an ASP.NET web form (and C# codebehind). I've got a bit of experience with web forms but not very complicated stuff, and haven't used much jquery before, and this is just puzzling me. I understand how to put it in and attach it to the element you want to be editable, it's what jeditable开发者_如何转开发 does when you submit the text field that I don't get. How do you handle that in the webform in order to save the changed text? Hope someone understands my issue... Cheers!


There are lots of ways to handle the POST that jEditable sends. I went with a very simple one. I made a new .aspx file and pointed jEditable to that. In there, you can access the form's POSTed fields with this.Request.Form["..."] to do whatever you intend to do. Here's a snippet:

protected override void OnLoad(EventArgs e)
{
    this.Response.Clear();
    this.Response.Cache.SetNoStore();
    this.Response.Cache.SetExpires(DateTime.Now);
    this.Response.StatusCode = 200;

    try
    {
        var postId = this.Request.Form["id"];
        var value = this.Request.Form["value"];

        this.Response.Write(value);

        switch (postId)
        {
            case "id1":
                // write 'value' to DB or whatever
                break;
            case "id2":
                // write 'value' to DB or whatever
                break;
            default:
                this.Response.StatusCode = 501; // Not Implemented
        }

        this.Response.End();
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜