qq_37965208
qq_37965208
2017-05-30 01:38
采纳率: 75%
浏览 979

asp.net,C sharp求大神帮写一下注释!越详细越好

 @{    var sname = "";    var snum = "";    var sid = "";    if (!IsPost)    {        if (!Request.QueryString["ID"].IsEmpty() && Request.QueryString["ID"].IsInt())        {            sid = Request.QueryString["ID"];            var db = Database.Open("startersite");            var dbCommand = "SELECT * FROM students WHERE sid = @0";            var row = db.QuerySingle(dbCommand, sid);            if (row != null)            {                sname = row.sname;                snum = row.snum;            }            else            {                Validation.AddFormError("没有找到这个ID的学生.");            }        }        else        {            Validation.AddFormError("没有找到这个ID的学生.");        }    }    //两个条件:第一,这是一个POST请求,第二,这是由一个叫做buttonDelete的按钮提交的请求    if (IsPost && !Request["buttonDelete"].IsEmpty())    {        sid = Request.Form["sid"];        var db = Database.Open("startersite");        var deleteCommand = "DELETE FROM students WHERE sid = @0";        db.Execute(deleteCommand, sid);        Response.Redirect("~/students");    }}<!DOCTYPE html><html lang="en"><head>    <title>删除学生信息</title></head><body>    <h1>删除学生信息</h1>    @Html.ValidationSummary()    <p><a href="~/students">返回学生列表</a></p>    <form method="post">        <fieldset>            <legend>学生信息</legend>            <p>                <span>学生姓名:</span>                <span>@sname</span>            </p>            <p>                <span>学号:</span>                <span>@snum</span>            </p>            <input type="hidden" name="sid" value="@sid" />            <p><input type="submit" name="buttonDelete" value="确认删除" /></p>        </fieldset>    </form></body></html>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • caozhy
    已采纳

    先把你的代码贴正确了。提问要用电脑提问,而不是用手机。还有先采纳之前的回答再问新的问题。

    点赞 评论

相关推荐