- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
出勤跟踪器应用程序的一部分,显示用户的主题并让他标记自己的出勤情况。
使用 enableviewstate="true",复选框不会被取消选中并且 checkchanged 事件不会执行。
namespace portal
{
public partial class tracker : System.Web.UI.Page
{
String[] split; string day;
protected void Page_Load(object sender, EventArgs e)
{
/* if (Session["uname"] == null)
{
Response.Redirect("Firstpage.aspx");
}*/
String[] split = new String[16];
DateTime d1 = DateTime.Today;
string month = d1.ToString("MMMM");
Lblmonth.Text = month;
String userid = Session["uname"].ToString();
SqlConnection con2 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd2 = new SqlCommand("select sbranch ,syear from studdetails where userid=@userid ", con2);
cmd2.Parameters.AddWithValue("userid", userid);
String branch = "", year = "";
SqlDataReader rdr2 = null;
con2.Open();
rdr2 = cmd2.ExecuteReader();
while (rdr2.Read())
{
branch = rdr2["sbranch"].ToString();
year = rdr2["syear"].ToString();
}
con2.Close();
int sem = 0;
switch (year)
{
case "B.E": sem = 8;
break;
case "T.E": sem = 6;
break;
case "S.E": sem = 4;
break;
case "F.E": sem = 2;
break;
default: sem = 2;
break;
}
int tempmonth = (int)(d1.Month);
if (tempmonth > 6)
sem = sem - 1;
SqlConnection con3 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd3 = new SqlCommand("select subject from subjecttable where department=@dept and semester=@sem ", con3);
cmd3.Parameters.AddWithValue("dept", branch);
cmd3.Parameters.AddWithValue("sem", sem);
con3.Open();
SqlDataReader rdr3 = null;
rdr3 = cmd3.ExecuteReader();
string subject = "";
while (rdr3.Read())
{
subject = rdr3["subject"].ToString();
}
con3.Close();
Char[] separator = new Char[] { ',' };
String[] subsplit = subject.Split(separator);
int size = subsplit.Length;
switch (size)
{
case 6: subj6.Text = subsplit[5];
goto case 5;
case 5: subj5.Text = subsplit[4];
goto case 4;
case 4: subj4.Text = subsplit[3];
goto case 3;
case 3: subj3.Text = subsplit[2];
goto case 2;
case 2: subj2.Text = subsplit[1];
goto case 1;
case 1: subj1.Text = subsplit[0];
break; ;
}
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsWeekend)
{
e.Cell.BackColor = System.Drawing.Color.DarkBlue;
}
else
{
e.Cell.BackColor = System.Drawing.Color.LightBlue;
}
SelectedDatesCollection dates = Calendar1.SelectedDates;
DateTime toDay = DateTime.Today;
string days = toDay.ToLongDateString();
Labelday.Text = days;
Char[] separator = new Char[] { ',' };
String[] split1 = days.Split(separator);
day = split1[0];
Session["day"] = Calendar1.SelectedDate.ToShortDateString();
if (dates.Count > 0)
{
Labelday.Text = dates[0].ToLongDateString() + "<br />";
String temp = Labelday.Text;
split1 = temp.Split(separator);
day = split1[0];
}
if (!(day.Equals("Saturday") || day.Equals("Sunday")))
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
string cla = Convert.ToString(Session["uclass"]);
SqlCommand cmd = new SqlCommand("select " + day + " from studtimetable where class = @class ", con);
con.Open();
cmd.Parameters.AddWithValue("class", cla);
SqlDataReader rdr = null;
String tt = "";
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
tt = rdr[day].ToString();
}
con.Close();
split = tt.Split(separator);
int size = split.Length;
lbltime.Visible = true;
Lblsubj.Visible = true;
Lblatt.Visible = true;
switch (size)
{
case 16: Label15.Text = split[15];
Session["l15"] = Label15.Text;
Label14.Text = split[14];
CheckBox8.Visible = true;
goto case 14;
case 14: Label13.Text = split[13];
Session["l13"] = Label13.Text;
Label12.Text = split[12];
CheckBox7.Visible = true;
goto case 12;
case 12: Label11.Text = split[11];
Session["l11"] = Label11.Text;
Label10.Text = split[10];
CheckBox6.Visible = true;
goto case 10;
case 10: Label9.Text = split[9];
Session["l9"] = Label9.Text;
Label8.Text = split[8];
CheckBox5.Visible = true;
goto case 8;
case 8: Label7.Text = split[7];
Session["l7"] = Label7.Text;
Label6.Text = split[6];
CheckBox4.Visible = true;
goto case 6;
case 6: Label5.Text = split[5];
Session["l5"] = Label5.Text;
Label4.Text = split[4];
CheckBox3.Visible = true;
goto case 4;
case 4: Label3.Text = split[3];
Session["l3"] = Label3.Text;
Label2.Text = split[2];
CheckBox2.Visible = true;
goto case 2;
case 2: Label1.Text = split[1];
Session["l1"] = Label1.Text;
Label0.Text = split[0];
CheckBox1.Visible = true;
break;
}
}
else
{
lbltime.Text = "Enjoy weekend";
lbltime.Visible = true;
}
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
CheckBox1.Checked = false;
CheckBox2.Checked = false;
CheckBox3.Checked = false;
CheckBox4.Checked = false;
CheckBox5.Checked = false;
CheckBox6.Checked = false;
CheckBox7.Checked = false;
CheckBox8.Checked = false;
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
string sub = Session["l1"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
}
else
{
Label18.Text = "uncheck";//temporary to check if this block executes
}
}
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox2.Checked == true)
{
string sub = Session["l3"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
//Response.Redirect("tracker.aspx");
}
else
{
}
}
protected void CheckBox3_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox3.Checked == true)
{
string sub = Session["l5"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
//Response.Redirect("tracker.aspx");
}
else
{
}
}
protected void CheckBox4_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox4.Checked == true)
{
string sub = Session["l7"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
//Response.Redirect("tracker.aspx");
}
else
{
}
}
protected void CheckBox5_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox5.Checked == true)
{
string sub = Session["l9"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
//Response.Redirect("tracker.aspx");
}
else
{
}
}
protected void CheckBox6_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox6.Checked == true)
{
string sub = Session["l11"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
//Response.Redirect("tracker.aspx");
}
else
{
}
}
protected void CheckBox7_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox7.Checked == true)
{
string sub = Session["l13"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
//Response.Redirect("tracker.aspx");
}
else
{
}
}
protected void CheckBox8_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox8.Checked == true)
{
string sub = Session["l15"].ToString();
string userid = Session["uname"].ToString();
string date = Session["day"].ToString();
string tempclass = Session["uclass"].ToString();
SqlConnection con4 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\mmm\portal\App_Data\student.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd4 = new SqlCommand("insert into " + tempclass + "track values ('" + userid + "','" + sub + "','" + date + "')", con4);
con4.Open();
cmd4.ExecuteNonQuery();
con4.Close();
//Response.Redirect("tracker.aspx");
}
else
{
}
}
}
}
最佳答案
来自 MSDN(http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkbox.oncheckedchanged.aspx):
A CheckBox control must persist some values between posts to the server for this event to work correctly. Be sure that view state is enabled for this control.
当 (html) 复选框未选中并提交表单时,不会将任何值传递回服务器,这就是为什么您需要为此控件启用 ViewState,以便 ASP.NET 跟踪状态(已选中/未选中).
关于c# - 为什么 checkedchanged 事件不会在取消选中 asp.net 中的复选框时触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15772642/
尝试使用集成到 QTCreator 的表单编辑器,但即使我将插件放入 QtCreator.app/Contents/MacOS/designer 也不会显示。不过,相同的 dylib 文件确实适用于独
在此代码示例中。 “this.method2();”之后会读到什么?在返回returnedValue之前会跳转到method2()吗? public int method1(int returnedV
我的项目有通过gradle配置的依赖项。我想添加以下依赖项: compile group: 'org.restlet.jse', name: 'org.restlet.ext.apispark', v
我将把我们基于 Windows 的客户管理软件移植到基于 Web 的软件。我发现 polymer 可能是一种选择。 但是,对于我们的使用,我们找不到 polymer 组件具有表格 View 、下拉菜单
我的项目文件夹 Project 中有一个文件夹,比如 ED 文件夹,当我在 Eclipse 中指定在哪里查找我写入的文件时 File file = new File("ED/text.txt"); e
这是奇怪的事情,这个有效: $('#box').css({"backgroundPosition": "0px 250px"}); 但这不起作用,它只是不改变位置: $('#box').animate
这个问题在这里已经有了答案: Why does OR 0 round numbers in Javascript? (3 个答案) 关闭 5 年前。 Mozilla JavaScript Guide
这个问题在这里已经有了答案: Is the function strcmpi in the C standard libary of ISO? (3 个答案) 关闭 8 年前。 我有一个问题,为什么
我目前使用的是共享主机方案,我不确定它使用的是哪个版本的 MySQL,但它似乎不支持 DATETIMEOFFSET 类型。 是否存在支持 DATETIMEOFFSET 的 MySQL 版本?或者有计划
研究 Seam 3,我发现 Seam Solder 允许将 @Named 注释应用于包 - 在这种情况下,该包中的所有 bean 都将自动命名,就好像它们符合条件一样@Named 他们自己。我没有看到
我知道 .append 偶尔会增加数组的容量并形成数组的新副本,但 .removeLast 会逆转这种情况并减少容量通过复制到一个新的更小的数组来改变数组? 最佳答案 否(或者至少如果是,则它是一个错
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
noexcept 函数说明符是否旨在 boost 性能,因为生成的对象中可能没有记录异常的代码,因此应尽可能将其添加到函数声明和定义中?我首先想到了可调用对象的包装器,其中 noexcept 可能会产
我正在使用 Angularjs 1.3.7,刚刚发现 Promise.all 在成功响应后不会更新 angularjs View ,而 $q.all 会。由于 Promises 包含在 native
我最近发现了这段JavaScript代码: Math.random() * 0x1000000 10.12345 10.12345 >> 0 10 > 10.12345 >>> 0 10 我使用
我正在编写一个玩具(物理)矢量库,并且遇到了 GHC 坚持认为函数应该具有 Integer 的问题。是他们的类型。我希望向量乘以向量以及标量(仅使用 * ),虽然这可以通过仅使用 Vector 来实现
PHP 的 mail() 函数发送邮件正常,但 Swiftmailer 的 Swift_MailTransport 不起作用! 这有效: mail('user@example.com', 'test
我尝试通过 php 脚本转储我的数据,但没有命令行。所以我用 this script 创建了我的 .sql 文件然后我尝试使用我的脚本: $link = mysql_connect($host, $u
使用 python 2.6.4 中的 sqlite3 标准库,以下查询在 sqlite3 命令行上运行良好: select segmentid, node_t, start, number,title
我最近发现了这段JavaScript代码: Math.random() * 0x1000000 10.12345 10.12345 >> 0 10 > 10.12345 >>> 0 10 我使用
我是一名优秀的程序员,十分优秀!