从asp.net c#codebehind事件获取html DIV内容

从asp.net c#codebehind事件获取html DIV内容,c#,jquery,asp.net,html,C#,Jquery,Asp.net,Html,我想通过asp.net C#代码隐藏事件获取HTML DIV内容 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="WebApplication1.Report.Report" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml

我想通过asp.net C#代码隐藏事件获取HTML DIV内容

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="WebApplication1.Report.Report" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type="text/javascript">

    $(document).ready(function () {

        $('#_Hidden_CrystalReportContent').hide();
        $('#_Hidden_CrystalReportContent').html("<b>I want to get Current value. 1<sup>st</sup></b>");

    });        
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="_Hidden_CrystalReportContent">I want to get Current value.</div>    
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</form>
</body>
</html>
但我仍然无法获取div内容值。
请让我听听您的建议。

让div runat=“server”在服务器上访问

Html

Javascript


我按照你的建议做了,但它只返回“我想得到当前值”。我想从Jquery函数“I want to get Current value.1st”中获得最多的更新值。但我无法获得更新的数据。请再次建议我,因为您正在访问document.ready。您需要将它放在某个函数中,并在需要时调用它。我创建了
按钮1 OnClientClick
,并将我的函数放在该客户端事件中。但是没有任何变化。你正在尝试获取更新的html?如果您无法在回发时获得它,则只会发布html表单元素。将更改放在某个隐藏字段中,并在服务器上对其进行评估。我不尝试使用隐藏字段的原因是我不知道需要动态附加到Div内容的HTML字符串数量。
public partial class Report : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}

protected void Button1_Click(object sender, EventArgs e)
{
    string s = Request["_Hidden_CrystalReportContent"].ToString();
}
}
<div id="_Hidden_CrystalReportContent" runat="server">
string htmlOfDiv = _Hidden_CrystalReportContent.innerHTML;
$(document).ready(function () {

    $('#<% _Hidden_CrystalReportContent.ClientID %>').hide();
    $('#<%= _Hidden_CrystalReportContent.ClientID %>').html("<b>I want to get Current value. 1<sup>st</sup></b>");

});        
<input type="hidden"  id="hdnDivContents" runat="server">
$('#<% hdnDivContents.ClientID %>').val("<b>I want to get Current value. 1<sup>st</sup></b>");
 _Hidden_CrystalReportContent.innerHTML = hdnDivContents.Value;