用asp怎么判断checkbox是没有被选中,还是处于不可选(disabled="true")状态?
用asp怎么判断checkbox是没有被选中,还是处于不可选(disabled="true")状态?因为用asp的request来获取一个checkbox,只能判断他的值...
用asp怎么判断checkbox是没有被选中,还是处于不可选(disabled="true")状态?
因为用asp的request来获取一个checkbox,只能判断他的值是多少,然而,checkbox在没有被选中和不可选的状态下,取到的值都是空。。。我想区分这两种情况,怎么判断呢?
------------------------------------------------------------------------
即:
<input type="checkbox" id="a" value="11">
和
<input type="checkbox" id="a" value="11" disabled="true">
用asp获取值的时候:<%=request("a")%>得到的值都是空字符串,怎么区分这两种情况呢??
一楼和二楼的答案都不靠谱啊。。。 展开
因为用asp的request来获取一个checkbox,只能判断他的值是多少,然而,checkbox在没有被选中和不可选的状态下,取到的值都是空。。。我想区分这两种情况,怎么判断呢?
------------------------------------------------------------------------
即:
<input type="checkbox" id="a" value="11">
和
<input type="checkbox" id="a" value="11" disabled="true">
用asp获取值的时候:<%=request("a")%>得到的值都是空字符串,怎么区分这两种情况呢??
一楼和二楼的答案都不靠谱啊。。。 展开
展开全部
简答举个例子你看看
这个应该可以实现该功能的,你可以仿这个改改
<%@ Language=VBScript %>
<HTML>
<TITLE>
订购水果
</TITLE>
<BODY>
请选择你所要订购的水果
<hr>
<FORM ACTION="order.asp">
<input name="fruit" type=checkbox value="苹果">苹果
<Br>
<input name="fruit" type=checkbox value="香蕉">香蕉
<Br>
<input name="fruit" type=checkbox value="菠萝">菠萝
<Br>
<input name="fruit" type=checkbox value="桔子">桔子
<input type=submit value="订购">
</FORM>
<hr>
<%
if Request.QueryString("fruit").Count=0 then
%>
你没有订购水果
<%else%>
你订购了
<%
for each fruit in Request("fruit")
response.write "<br><font color=green>" & fruit & "</font>"
next
end if
%>
</BODY>
</HTML>
0
这个应该可以实现该功能的,你可以仿这个改改
<%@ Language=VBScript %>
<HTML>
<TITLE>
订购水果
</TITLE>
<BODY>
请选择你所要订购的水果
<hr>
<FORM ACTION="order.asp">
<input name="fruit" type=checkbox value="苹果">苹果
<Br>
<input name="fruit" type=checkbox value="香蕉">香蕉
<Br>
<input name="fruit" type=checkbox value="菠萝">菠萝
<Br>
<input name="fruit" type=checkbox value="桔子">桔子
<input type=submit value="订购">
</FORM>
<hr>
<%
if Request.QueryString("fruit").Count=0 then
%>
你没有订购水果
<%else%>
你订购了
<%
for each fruit in Request("fruit")
response.write "<br><font color=green>" & fruit & "</font>"
next
end if
%>
</BODY>
</HTML>
0
展开全部
HTML代码:
<asp:GridView id="GridView1" runat="server" DataKeyNames="id" AllowSorting="True" AutoGenerateColumns="False" OnRowDeleting="GridView1_RowDeleting" SkinID="gvSkin" Width="100%" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" Width="3%" />
<ItemTemplate>
<asp:CheckBox ID="ckbDelete" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="NameNews" HeaderText="新闻标题" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="TypeNews" HeaderText="新闻类型">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="PeopleNews" HeaderText="发布人">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="DateNews" DataFormatString="" HeaderText="添加日期"
HtmlEncode="False">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="ButtonNews" HeaderText="点击数">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="News_Modfiy.aspx?id="
HeaderText="操作" Text="修改" >
<ItemStyle HorizontalAlign="Center" Width="6%" />
</asp:HyperLinkField>
<asp:CommandField HeaderText="操作" ShowDeleteButton="True" DeleteText="<div id="de" onclick="JavaScript:return confirm('确定删除吗?')">删除</div>" >
<ItemStyle HorizontalAlign="Center" Width="6%" />
</asp:CommandField>
</Columns>
</asp:GridView>
<asp:CheckBox id="CheckBox1" runat="server" Text=" 选中/取消所有" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged"></asp:CheckBox> <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="删除选中项" OnClientClick='return confirm("你确定要删除?")'></asp:Button>
=================================.cs代码
protected void Button1_Click(object sender, EventArgs e)
{
for (int rowindex = 0; rowindex < this.GridView1.Rows.Count; rowindex++)
{
if (((CheckBox)this.GridView1.Rows[rowindex].Cells[0].FindControl("ckbDelete")).Checked == true)
{
int intID = Convert.ToInt32(this.GridView1.DataKeys[rowindex].Value);
string strSql = "DELETE FROM OC_Product WHERE id=" + intID;
//对数据库执行删除操作省略
}
}
ShowNews();
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
foreach (GridViewRow row in GridView1.Rows)
{
((CheckBox)row.Cells[0].FindControl("ckbDelete")).Checked = true;
}
}
else
{
foreach (GridViewRow row in GridView1.Rows)
{
((CheckBox)row.Cells[0].FindControl("ckbDelete")).Checked = false;
}
}
}
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
<asp:GridView id="GridView1" runat="server" DataKeyNames="id" AllowSorting="True" AutoGenerateColumns="False" OnRowDeleting="GridView1_RowDeleting" SkinID="gvSkin" Width="100%" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" Width="3%" />
<ItemTemplate>
<asp:CheckBox ID="ckbDelete" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="NameNews" HeaderText="新闻标题" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="TypeNews" HeaderText="新闻类型">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="PeopleNews" HeaderText="发布人">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="DateNews" DataFormatString="" HeaderText="添加日期"
HtmlEncode="False">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="ButtonNews" HeaderText="点击数">
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="News_Modfiy.aspx?id="
HeaderText="操作" Text="修改" >
<ItemStyle HorizontalAlign="Center" Width="6%" />
</asp:HyperLinkField>
<asp:CommandField HeaderText="操作" ShowDeleteButton="True" DeleteText="<div id="de" onclick="JavaScript:return confirm('确定删除吗?')">删除</div>" >
<ItemStyle HorizontalAlign="Center" Width="6%" />
</asp:CommandField>
</Columns>
</asp:GridView>
<asp:CheckBox id="CheckBox1" runat="server" Text=" 选中/取消所有" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged"></asp:CheckBox> <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="删除选中项" OnClientClick='return confirm("你确定要删除?")'></asp:Button>
=================================.cs代码
protected void Button1_Click(object sender, EventArgs e)
{
for (int rowindex = 0; rowindex < this.GridView1.Rows.Count; rowindex++)
{
if (((CheckBox)this.GridView1.Rows[rowindex].Cells[0].FindControl("ckbDelete")).Checked == true)
{
int intID = Convert.ToInt32(this.GridView1.DataKeys[rowindex].Value);
string strSql = "DELETE FROM OC_Product WHERE id=" + intID;
//对数据库执行删除操作省略
}
}
ShowNews();
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
foreach (GridViewRow row in GridView1.Rows)
{
((CheckBox)row.Cells[0].FindControl("ckbDelete")).Checked = true;
}
}
else
{
foreach (GridViewRow row in GridView1.Rows)
{
((CheckBox)row.Cells[0].FindControl("ckbDelete")).Checked = false;
}
}
}
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用ASP是不能判断处于不可选(disabled="true")状态的,只能用JAVASCRIPT
if(document.getElementById("a").disabled="true")
或者
if(document.getElementById("a").disabled="disabled")
if(document.getElementById("a").disabled="true")
或者
if(document.getElementById("a").disabled="disabled")
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
反正是只读的
放两个 ,一个checkbox用来显示 hidden 用来取值
<input type="checkbox" checked="true" disabled="true" />
<input type="hidden" name="a" value="1" />
放两个 ,一个checkbox用来显示 hidden 用来取值
<input type="checkbox" checked="true" disabled="true" />
<input type="hidden" name="a" value="1" />
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给commandname负值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询