找不到资源错误我正在点击按钮 [英] Resource Not Found Error Coming Whaen I Am Clicking On Button

查看:59
本文介绍了找不到资源错误我正在点击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的索引页



my index page

@model MvcApplication90.vikrant

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<html>
<head>
    <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
    <script type ="text/javascript">
        $("#submit").click(function () {

            var url = "/Home/Index";
            var name = $("#name").val()
            var address = $("#address").val()
            $.post(url, { Name: name, Address: address }, function (data) {
                $("#result").html(data)


            })
        })
</script>
    
</head>
<body>

<h2>Index</h2>
@section Feature
{
    @using (Html.BeginForm( "Home","Index", FormMethod.Post, new { id = "frm"}))
    {
        <table>
            <tr>
                <td> 
                @Html.LabelFor(model => model.name)
                @Html.TextBoxFor( Model => Model.name)
                
                </td>
            </tr>

            <tr>
                <td>
                    @Html.LabelFor( model => model.address)
                    @Html.TextBoxFor( model => model.address)
                </td>
            </tr>
           <tr>
               <td>
               <input type ="submit" id ="dd", value ="submit" />
                   </td>
           </tr>
        </table>
      <div id="result" style="color:gray;"></div>
    }

  
        </body>
</html>



layoutpage


layoutpage

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
    
    <script src="@Url.Content("~/Scripts/modernizr-2.5.3.js")" type="text/javascript"></script>
    
</head>

<body>
    @RenderBody()
    @RenderSection("Feature")

</body>
</html>





CONTROLER





CONTROLER

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;



namespace MvcApplication90.Controllers
{
    public class HomeController : Controller
    {
        [HttpGet]
        [ActionName("Index")]
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        [ActionName("Index")]
        public ActionResult Index( FormCollection formcollection)
        {
            vikrant cc = new vikrant();
            cc.name = formcollection["name"];
            cc.address = formcollection["address"];
            hospitalEntities tt = new hospitalEntities();
            tt.addemp(cc);
            return "thank u" + Name + "SUBMITTED";
          


        }

    }
}



请帮助我< strike> ITS URGENT

推荐答案

#submit)。click( function (){

var url = / Home / Index;
var name =
("#submit").click(function () { var url = "/Home/Index"; var name =


#name )。val()
var address =
("#name").val() var address =


#address)。val()


这篇关于找不到资源错误我正在点击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆