任务要求:一组RadioButton,分别对应一个TextBox,当RadioButton被选中时,其后的TextBox置为不可用。 //testControlPage.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testControlPage.aspx.cs" Inherits="testControlPage" %> <!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 language="javascript" type="text/javascript">
function RBchecked() {
var a = document.getElementsByName("a");
for (var i=0; i<a.length; i++) {
if(a.checked) {
var tb = document.getElementsByName("tb"+i);
tb[0].readOnly=true;
}
else {
var tbf = document.getElementsByName("tb"+i);
if (tbf[0].readOnly==true)
tbf[0].readOnly=false;
}
}
}
</script>
</head>
<body >
<form id="form1" runat="server" >
<div>
<asp:RadioButton id=rb0 GroupName="a" runat="server" />
<asp:TextBox id=tb0 name="tb" runat="server" />
<asp:RadioButton id=rb1 GroupName="a" runat="server" />
<asp:TextBox id=tb1 name="tb" runat="server" />
<asp:RadioButton id=rb2 GroupName="a" runat="server" />
<asp:TextBox id=tb2 name="tb" runat="server" />
<input type=button id="test" value="测试" disabled=disabled />
</div>
</form>
</body>
</html>
//testControlPage.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class testControlPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
rb0.Attributes.Add("onclick", "JavaScript:RBchecked();");
rb1.Attributes.Add("onclick", "JavaScript:RBchecked();");
rb2.Attributes.Add("onclick", "JavaScript:RBchecked();");
}
}
分享到:
相关推荐
NULL 博文链接:https://yezhiqiu-love-yeah-net.iteye.com/blog/751325
该属性默许值为false,即修注释本后并不立刻回发到效力器,而是等窗体被提交后一并处置。 2) TextMode属性:用于设置文本框接受文本的行为方式。共有三种属性值:MultiLine〔多行输入方式〕;Password〔密码输入方式...
TextBox1.Font = New Font(TextBox1.Font.FontFamily, TextBox1.Font.Size, TextBox1.Font.Style) End Sub Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs...
MessageBox.Show("通讯录里已有一个同名的联系人,不能插入同名联系人"); for(int m=0;m;m++) { p[i,m]=""; } i--; num--; break; } else ...
A 模数运算符 模数运算符 (%) 计算第二个操作数除第一个操作数后的余数。所有数值类 型都具有预定义的模数运算符。如 Console.WriteLine(5 % 2); Console.WriteLine(-5 % 2); Console.WriteLine(5.0 % 2.2); ...
实验2(1)构造一个类,可以分别对任意多个整数、小数或字符串进行排序。 实验3编写一个程序,计算两个指定年份之间的闰年并输出,运行界面如图6.5所示。 要求:利用组合框选择或输入起止年份,起始年份不能大于...
把RadioButton0,1,2放一个容器里! Public Class Form1 Dim win1 As Integer = 0 Dim win2 As Integer = 0 Dim i As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System....
直接把NICTCASA.DLL 添加引用 把DATA文件放入bin Debug Data... private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } }
if (radioButton1.Checked == true) { String user = textBox1.Text.Trim(); String password = textBox2.Text.Trim(); if (user == "") { MessageBox.Show("用户名不能为空,请重新输入!!", "Error"); ...
If RadioButton1.Checked Then Dim mycmd As New SqlCommand(str1, myconn) myconn.Open() Dim myReader As SqlDataReader myReader = mycmd.ExecuteReader() If myReader.HasRows = False Then MsgBox(...
--我们做了优化,现在要使一个Asp.net的按钮能够AJAX提交,你不需要做任何设置(PageManager的属性EnableAjax为true即可,这是默认属性)。 +PageManager的实例方法AddAjaxUpdateControl改名为...
-如果TreeNode的属性Enabled="false",则此项变灰并且不会被选中(feedback:your568)。 -修正TreeNode的属性NavigateUrl不接受服务器端URL(以~/开头)的BUG。 -增加Accordion和Tree配合使用的示例(other\...
5.1 显示静态文本 79 5.2 TextBox控件 80 5.3 Button控件 82 5.4 单选按钮和单选按钮列表 84 5.4.1 RadioButton控件 84 5.4.2 RadioButtonList控件 86 ...5.12.3 如何让一个控件只在需要的时候显示 101
网上的类,很感兴趣,写了这个DES文件加密程序,已测试通过。 补充 button3_Click改为下述代码: private void button3_Click(object sender, EventArgs e) { sFileIn = this.textBox1.Text; sFileOut = this....
海康威视LED屏DS-TVL... if (radioButton1.Checked) { text_color = Color.Red; } else { text_color = Color.Green; } led.led_show(textBox4.Text, text_color, out err); Debug.Print(err); }
If (TextBox1.Text = "jolan" And RadioButton1.Checked = True) Or (TextBox1.Text <> "jolan" And RadioButton2.Checked = True) Then Form5.Show() Me.Hide() Exit For End If End If End If Next If ...
string sql = "SELECT Name,PassWord FROM Admin WHERE Name='" + this.textBox1.Text + "'and PassWord='" + this.textBox2.Text + "'"; SqlCommand Cmd = new SqlCommand(sql, Conn); SqlDataReader reader = ...
一套蓝色的siverlight控件样式包括button,textbox,ComboBox,RadioButton,-CheckBox等11个控件样式
对search方法略作修改,查不到字符时返回起始位置; public void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Length > 0) { str = textBox1.Text; fm.searchStr = textBox1.Text; ...
If Me.RadioButton1.Checked Then Dim str As String str = "data source=PC-201103171305\SQLEXPRESS;database=学生信息库;user id=sa;pwd=" Dim con As New SqlClient.SqlConnection(str) Try con.Open() ...