首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请问用C#帮小弟我实现下面程序的功能

2012-02-01 
请教用C#帮我实现下面程序的功能Private Sub Page_Load(ByVal sender As System.Object, ByVal e As Syste

请教用C#帮我实现下面程序的功能
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  ' Save DepartmentID from the query string to a variable
  Dim departmentId As String = Request.QueryString("DepartmentID")
  ' If no department is selected, this control should be invisible
  If IsNumeric(departmentId) Then
  Me.Visible = False
  ElseIf Not Page.IsPostBack Then
  ' Update the data grid
  BindDepartments()
  End If
  End Sub

[解决办法]
Private void Page_Load(Object sender, EventArgs e)
{
 string departmentId = Request.QueryString("DepartmentID");
 if (IsNumeric(departmentId))
 {
Me.Visible = false;
 }
 else if(!Page.IsPostBack)
 {
BindDepartments()
 }
}
[解决办法]

MyBase.Load +=Page_Load;
Private Page_Load(System.Object sender ,System.EventArgs e )
{
// Save DepartmentID from the query string to a variable 
String departmentId = Request.QueryString("DepartmentID").toString(); 
// If no department is selected, this control should be invisible 
If (IsNumeric(departmentId))
Me.Visible = False ;
ElseIf(!Page.IsPostBack) 
//Update the data grid 
BindDepartments() ;
 }
//这样?
[解决办法]
IsNumeric方法,c#中没有的。但
可以用正则表达式判断,同样的效果
[解决办法]

C# code
if (!String.IsNullOrEmpty(string变量) && !System.Text.RegularExpressions.Regex.IsMatch(string变量, "\\D")
[解决办法]
C# code
public class
[解决办法]
Private void Page_Load(Object sender, EventArgs e) 

 string departmentId = Request.QueryString("DepartmentID"); 
 if (IsNumeric(departmentId)) 
 { 
Me.Visible = false; 
 } 
 else if(!Page.IsPostBack) 
 { 
BindDepartments() 
 } 
}

try
{
convert.todouble(departmentId);
Me.Visible = false; 

}
catch
{
if(!Page.IsPostBack) 
 { 
BindDepartments() 
 } 
}

热点排行