Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用于检查复选框值的代码块_C#_Asp.net - Fatal编程技术网

C# 用于检查复选框值的代码块

C# 用于检查复选框值的代码块,c#,asp.net,C#,Asp.net,我是ASP和C的新手,需要一些关于ASPX中C代码块的建议。我已尝试根据复选框值更改标签文本 它不起作用,我不确定这是否是正确的方法 首先,您必须为..使用javascript或jquery。。由于aspx是一种服务器端语言,因此一旦加载,它将无法控制网页。首先,您必须使用javascript或jquery来实现。。由于aspx是一种服务器端语言,一旦加载,它将无法控制网页。这是因为true仅用小写字母拼写。 您的代码工作正常,我假设您没有使用IDE,因为它会告诉您未定义True。您必须将其

我是ASP和C的新手,需要一些关于ASPX中C代码块的建议。我已尝试根据复选框值更改标签文本



它不起作用,我不确定这是否是正确的方法

首先,您必须为..使用javascript或jquery。。由于aspx是一种服务器端语言,因此一旦加载,它将无法控制网页。

首先,您必须使用javascript或jquery来实现。。由于aspx是一种服务器端语言,一旦加载,它将无法控制网页。

这是因为true仅用小写字母拼写。
您的代码工作正常,我假设您没有使用IDE,因为它会告诉您未定义
True
。您必须将其更改为
true

<% if (CheckBox1.Checked==true)   {%> 

这是因为true仅用小写字母拼写。
您的代码工作正常,我假设您没有使用IDE,因为它会告诉您未定义
True
。您必须将其更改为
true

<% if (CheckBox1.Checked==true)   {%> 

最好将标记和代码分成两个不同的文件(例如Default.aspx和Default.aspx.cs)。 若要更改标签文本,请尝试处理页面的加载事件

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<form id="form1" runat="server">
<asp:CheckBox runat="server" id="CheckBox1" AutoPostBack="True" Checked="True"></asp:CheckBox>
<asp:Label id="Label1" runat="server"></asp:Label>
</form>
</body>
</html>

最好将标记和代码分成两个不同的文件(例如Default.aspx和Default.aspx.cs)。 若要更改标签文本,请尝试处理页面的加载事件

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<form id="form1" runat="server">
<asp:CheckBox runat="server" id="CheckBox1" AutoPostBack="True" Checked="True"></asp:CheckBox>
<asp:Label id="Label1" runat="server"></asp:Label>
</form>
</body>
</html>
看看这个,它会起作用的看看这个,它会起作用的