[英]c# winforms control loop method in asp.net
我在winforms c#中获得了这种方法,它可以完美工作。 但是我无法弄清楚如何使asp.net网页的此方法完全相同。 任何一点帮助将不胜感激。
public static void rat(Form x)
{
Form myForm = x;
foreach (Control c in myForm.Controls)
{
if (c.Name != "ctn" && !(c is Label))
{
c.Enabled = !(c.Enabled);
}
}
}
只需更改以下两行。 由于它是ASP.NET
应用程序,因此您期望使用Page
实例而不是Form
实例。 因为每个ASP.NET
Web窗体所继承Page
在基类中同样Winform
各种形式从继承Form
基类。
public static void rat(Page x)
{
Page myPage = x;
考虑到您的Webform名称为webform1
,您可以执行此操作
public static void rat(Page x)
{
webform1 myForm = (webform1)x;
foreach (Control c in myForm.Controls)
{
if (c.Name != "ctn" && !(c is Label))
{
((Label)c).Enabled = !((Label)c).Enabled);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.