"With" in c#

  • Thread starter Thread starter sck10
  • Start date Start date
S

sck10

Hello,

Is there the equivalent of the "with" command in c#?


protected void SetFocusControl(Control FocusControl)
{

System.Text.StringBuilder script = New System.Text.StringBuilder();
string ClientID = FocusControl.ClientID;
With script{
.Append["<script language='javascript'>"];
.Append("document.getElementById('");
.Append(ClientID);
.Append("').focus();");
.Append("</script>");
} //End With
Me.Clientscript.RegisterStartupscript(GetType(String),
"SetFocusControl", script.ToString());

}
 
Nor should there be, IMHO.

--
-Demetri


Winista said:
no

sck10 said:
Hello,

Is there the equivalent of the "with" command in c#?


protected void SetFocusControl(Control FocusControl)
{

System.Text.StringBuilder script = New System.Text.StringBuilder();
string ClientID = FocusControl.ClientID;
With script{
.Append["<script language='javascript'>"];
.Append("document.getElementById('");
.Append(ClientID);
.Append("').focus();");
.Append("</script>");
} //End With
Me.Clientscript.RegisterStartupscript(GetType(String),
"SetFocusControl", script.ToString());

}
 
You can find out about why at:
http://www.gotdotnet.com/team/csharp/learn/columns/ask.aspx#with

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Winista said:
no

sck10 said:
Hello,

Is there the equivalent of the "with" command in c#?


protected void SetFocusControl(Control FocusControl)
{

System.Text.StringBuilder script = New System.Text.StringBuilder();
string ClientID = FocusControl.ClientID;
With script{
.Append["<script language='javascript'>"];
.Append("document.getElementById('");
.Append(ClientID);
.Append("').focus();");
.Append("</script>");
} //End With
Me.Clientscript.RegisterStartupscript(GetType(String),
"SetFocusControl", script.ToString());

}
 
Fortunately, Microsoft saw fit to create C# from the ground up, which some
people say gave them the luxury of leaving out all the little crutches and
bad-programming practices constructs that more or less "had" to come along
for the ride in VB.NET.
And "With" is one of them.
Peter
 
Back
Top