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

need help translating VB.NET -> C#

P: n/a
I'm tring to translate an VB.NET method into C#. Here is what I've done so
far. Need help on the while loop

public static void SetInitialFocus(Control ctrl)
{
StringBuilder s = new StringBuilder();
s.Append("<SCRIPT LANGUAGE='JavaScript'>");
s.Append("function SetInitialFocus()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (Not typeof p Is System.Web.UI.HtmlControls.HtmlForm)
{
p = p.Parent;
}
s.Append(p.ClientID);
s.Append("['");
s.Append(ctrl.UniqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("window.onload = SetInitialFocus;");
s.Append("</SCRIPT>");
ctrl.Page.RegisterClientScriptBlock("InitialFocus" , s.ToString());
}
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
public static void SetInitialFocus(Control ctrl)
{
StringBuilder s = new StringBuilder();
s.Append("<SCRIPT LANGUAGE='JavaScript'");
s.Append("function SetInitialFocus()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (p.GetType() != typeof(System.Web.UI.HtmlControls.HtmlForm))
{
p = p.Parent;
}
s.Append(p.ClientID);
s.Append("['");
s.Append(ctrl.UniqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("window.onload = SetInitialFocus;");
s.Append("</SCRIPT");
ctrl.Page.RegisterClientScriptBlock("InitialFocus" , s.ToString());
}

Might do it

MattC
"Eirik Eldorsen" <ku*******@hotmail.com> wrote in message
news:#u**************@TK2MSFTNGP11.phx.gbl...
I'm tring to translate an VB.NET method into C#. Here is what I've done so
far. Need help on the while loop

public static void SetInitialFocus(Control ctrl)
{
StringBuilder s = new StringBuilder();
s.Append("<SCRIPT LANGUAGE='JavaScript'>");
s.Append("function SetInitialFocus()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (Not typeof p Is System.Web.UI.HtmlControls.HtmlForm)
{
p = p.Parent;
}
s.Append(p.ClientID);
s.Append("['");
s.Append(ctrl.UniqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("window.onload = SetInitialFocus;");
s.Append("</SCRIPT>");
ctrl.Page.RegisterClientScriptBlock("InitialFocus" , s.ToString());
}

Nov 18 '05 #2

P: n/a
> while (Not typeof p Is System.Web.UI.HtmlControls.HtmlForm)

Do this:
while (!(p is HtmlForm)

Anders Norås
blog: http://dotnetjunkies.com/weblog/anoras/
Nov 18 '05 #3

P: n/a
Try this, no worries

http://www.developerfusion.com/utili...btocsharp.aspx

hope this help!

weichung

"Eirik Eldorsen" wrote:
I'm tring to translate an VB.NET method into C#. Here is what I've done so
far. Need help on the while loop

public static void SetInitialFocus(Control ctrl)
{
StringBuilder s = new StringBuilder();
s.Append("<SCRIPT LANGUAGE='JavaScript'>");
s.Append("function SetInitialFocus()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (Not typeof p Is System.Web.UI.HtmlControls.HtmlForm)
{
p = p.Parent;
}
s.Append(p.ClientID);
s.Append("['");
s.Append(ctrl.UniqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("window.onload = SetInitialFocus;");
s.Append("</SCRIPT>");
ctrl.Page.RegisterClientScriptBlock("InitialFocus" , s.ToString());
}

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.