need help translating VB.NET -> C#

E

Eirik Eldorsen

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());
}
 
M

MattC

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top