ASP.NET如何在客户端设置属性?

ASP.NET如何在客户端设置属性?,asp.net,Asp.net,在将数据发送到服务器之前,我试图在客户端设置一些数据,但它并没有给我任何更改 div包含以下数据: <div id="chanelValues" data-value="0" runat="server"></div> 如何获取更新的数据 谢谢 也许我把你的问题搞错了,但我会试试 您需要一个模型作为服务器和客户端之间的接口 using System; namespace MvcMovie.Models {

在将数据发送到服务器之前,我试图在客户端设置一些数据,但它并没有给我任何更改

div包含以下数据:

<div id="chanelValues" data-value="0" runat="server"></div>
如何获取更新的数据


谢谢

也许我把你的问题搞错了,但我会试试

您需要一个模型作为服务器和客户端之间的接口

        using System;

         namespace MvcMovie.Models
         {
                public class Movie
                {
                     public int ID { get; set; }
                     public string Title { get; set; }
                     public DateTime ReleaseDate { get; set; }
                     public string Genre { get; set; }
                     public decimal Price { get; set; }
                }
         }

@model MvcMovie.Models.Movie
@{
ViewBag.Title=“详细信息”;
}
细节
电影

@DisplayNameFor(model=>model.Title) @*为清晰起见,省略标记。*@ @ActionLink(“编辑”,“编辑”,新的{id=Model.id})| @ActionLink(“返回列表”、“索引”)


您可以看看酒店

控制器:

public ActionResult SomeAction()
{
    // you could return a PartialView here if you need more complex HTML fragment
    return Content("<span>some content</span>", "text/html");
}
public ActionResult SomeAction()
{
//如果需要更复杂的HTML片段,可以在此处返回PartialView
返回内容(“某些内容”、“文本/html”);
}
视图:



如何将表单发回服务器?您的输入标签上不需要runat=server吗?您可以为
dropdownClick
共享javascript代码吗?我认为问题不是来自输入tag@Prabhat这是我的js代码$('chanelValues').attr('data-value',newValues);它工作正常什么是
下拉菜单单击
?这是ASP.NET MVC还是ASP.NET Web表单?感谢您的努力,但以下帖子标记在ASP.NET下,您的解决方案属于PHP。ohh抱歉,我将尝试在ASP.NET@Nh中找到解决方案ạHoán感谢你的MVC代码@hammerthea。你用ASP.NET试过了吗?是的,我用ASP.NET试过了如果你还有任何问题,只要问一下或者看看链接就可以了
        using System;

         namespace MvcMovie.Models
         {
                public class Movie
                {
                     public int ID { get; set; }
                     public string Title { get; set; }
                     public DateTime ReleaseDate { get; set; }
                     public string Genre { get; set; }
                     public decimal Price { get; set; }
                }
         }
  @model MvcMovie.Models.Movie

   @{
      ViewBag.Title = "Details";
   }

  <h2>Details</h2>

  <div>
      <h4>Movie</h4>
  <hr />
      <dl class="dl-horizontal">
          <dt>
              @Html.DisplayNameFor(model => model.Title)
          </dt>
           @*Markup omitted for clarity.*@        
      </dl>
  </div>
 <p>
     @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
     @Html.ActionLink("Back to List", "Index")
 </p>
public ActionResult SomeAction()
{
    // you could return a PartialView here if you need more complex HTML fragment
    return Content("<span>some content</span>", "text/html");
}
<div id="result"></div>
<%= Ajax.ActionLink(
    "Update div test", 
    "SomeAction", 
    new AjaxOptions { UpdateTargetId = "result" }
) %>