By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

"With" in c#

P: n/a
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(Stri ng),
"SetFocusControl", script.ToString());

}
--
Thanks in advance,

sck10
Jul 26 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
no

"sck10" <sc***@online.nospamwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...
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(Stri ng),
"SetFocusControl", script.ToString());

}
--
Thanks in advance,

sck10

Jul 26 '06 #2

P: n/a
Nor should there be, IMHO.

--
-Demetri
"Winista" wrote:
no

"sck10" <sc***@online.nospamwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...
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(Stri ng),
"SetFocusControl", script.ToString());

}
--
Thanks in advance,

sck10


Jul 26 '06 #3

P: n/a
You can find out about why at:
http://www.gotdotnet.com/team/csharp.../ask.aspx#with

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Winista" <wi*****@gmail.comwrote in message
news:eg**************@TK2MSFTNGP02.phx.gbl...
no

"sck10" <sc***@online.nospamwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...
>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(Stri ng),
"SetFocusControl", script.ToString());

}
--
Thanks in advance,

sck10


Jul 26 '06 #4

P: n/a
"sck10" <sc***@online.nospamwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...
Is there the equivalent of the "with" command in c#?
Thankfully, no.
Jul 26 '06 #5

P: n/a
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sck10" wrote:
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(Stri ng),
"SetFocusControl", script.ToString());

}
--
Thanks in advance,

sck10
Jul 26 '06 #6

P: n/a
As the other posters mentioned, you may want to rethink your need for this.
However, using abbreviated variables you can provide a near equivalent, but
this highlights the problem with 'With' in the first place:
http://www.tangiblesoftwaresolutions...0VB%20With.htm
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
"sck10" wrote:
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(Stri ng),
"SetFocusControl", script.ToString());

}
--
Thanks in advance,

sck10
Jul 27 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.