473,757 Members | 8,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need help translating VB.NET -> C#

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("<SCRI PT LANGUAGE='JavaS cript'>");
s.Append("funct ion SetInitialFocus ()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (Not typeof p Is System.Web.UI.H tmlControls.Htm lForm)
{
p = p.Parent;
}
s.Append(p.Clie ntID);
s.Append("['");
s.Append(ctrl.U niqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("windo w.onload = SetInitialFocus ;");
s.Append("</SCRIPT>");
ctrl.Page.Regis terClientScript Block("InitialF ocus", s.ToString());
}
Nov 18 '05 #1
3 1266
public static void SetInitialFocus (Control ctrl)
{
StringBuilder s = new StringBuilder() ;
s.Append("<SCRI PT LANGUAGE='JavaS cript'");
s.Append("funct ion SetInitialFocus ()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (p.GetType() != typeof(System.W eb.UI.HtmlContr ols.HtmlForm))
{
p = p.Parent;
}
s.Append(p.Clie ntID);
s.Append("['");
s.Append(ctrl.U niqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("windo w.onload = SetInitialFocus ;");
s.Append("</SCRIPT");
ctrl.Page.Regis terClientScript Block("InitialF ocus", s.ToString());
}

Might do it

MattC
"Eirik Eldorsen" <ku*******@hotm ail.com> wrote in message
news:#u******** ******@TK2MSFTN GP11.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("<SCRI PT LANGUAGE='JavaS cript'>");
s.Append("funct ion SetInitialFocus ()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (Not typeof p Is System.Web.UI.H tmlControls.Htm lForm)
{
p = p.Parent;
}
s.Append(p.Clie ntID);
s.Append("['");
s.Append(ctrl.U niqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("windo w.onload = SetInitialFocus ;");
s.Append("</SCRIPT>");
ctrl.Page.Regis terClientScript Block("InitialF ocus", s.ToString());
}

Nov 18 '05 #2
> while (Not typeof p Is System.Web.UI.H tmlControls.Htm lForm)

Do this:
while (!(p is HtmlForm)

Anders Norås
blog: http://dotnetjunkies.com/weblog/anoras/
Nov 18 '05 #3
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("<SCRI PT LANGUAGE='JavaS cript'>");
s.Append("funct ion SetInitialFocus ()");
s.Append("{");
s.Append(" document.");
Control p = ctrl.Parent;
while (Not typeof p Is System.Web.UI.H tmlControls.Htm lForm)
{
p = p.Parent;
}
s.Append(p.Clie ntID);
s.Append("['");
s.Append(ctrl.U niqueID);
s.Append("'].focus();");
s.Append("}");
s.Append("windo w.onload = SetInitialFocus ;");
s.Append("</SCRIPT>");
ctrl.Page.Regis terClientScript Block("InitialF ocus", s.ToString());
}

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1560
by: Davis Marques | last post by:
hi; I'm translating some PHP scripts to Python and have hit a roadblock with a for statement. If someone could explain to me how one should translate the multiple increment, evaluations, etc. in the first line I would appreciate it deeply ... for ($y = 0, $x = $cx-$cy-1; $y <= $cy; ++$y,++$x) { $prd = $q * $y_ar + $car; $prd -= ($car = intval($prd / 1E7)) * 1E7;
2
1447
by: Henrik S. Hansen | last post by:
How do you best go about translating characters like '\\n' to '\n'? This is for a configuration file parser, where the "backslash convention" is supported. The naive approach -- re.sub('\\\\(.)', '\\\1', s) -- doesn't work, of course. The best I've come up with so far is a special case for every character to be translated. There must be an easier way? -- Henrik S. Hansen http://freecode.dk/~hsh/
1
2044
by: Michael Friendly | last post by:
I have a LaTeX document describing a long list of items that I want to translate to XML to treat these as a database. I've written a perl script to do the basic translation, and a basic DTD file, but I am stumped at translating LaTeX character encodings to something XML won't choke on. I found GNU recode to solve most of this, using cat milestone.tex | recode -d tex..xml | itemdb -s xml -o milestone.xml
23
3153
by: gregf | last post by:
I have a paragraph of text pasted into a word document, it's in Polish, complete with polish characters. They show up just fine in word, but the program I use for web page programming, HomeSite, won't translate it. When I paste the text into the code, the special characters are missing. If they would show up there I could use the Replace Special Characters feature to change it to the proper code, but it won't even paste into it...
0
1121
by: Dylan Phillips | last post by:
I'm interested in how other participants in this new group are implementing SQL Full-Text Search on their Web Sites. How are you translating the user search string: "DirectX managed code" into the contains statement syntax ' "DirectX" AND "managed" AND "code" '? I started writing a query parsers as an intermediary to handle control characters like , but frankly it's becoming a rather pain in the a$$. If anyone has any suggestions as...
9
5676
by: Hugo Amselschlag | last post by:
Hi there, I've implemented a local system hook to suppress certain windows beeing displayed by the axWebbrowser control. Now I need some more information before I can decide, whether to suppress a window or not. My callback function get a long pointer (lParam) to a structure which contains further information. This structure is described at MSN as follows: typedef struct tagCREATESTRUCT {
6
2533
by: Jumping Matt Flash | last post by:
The code i'm writing is using VB .NET and is for a web service returning a dataset, which is in turn to be used by an ASP .NET application displaying a datagrid. I'm currently populating a datagrid using a "select top 1 column 1, column2, column3 from tblTable" statement. As there will only ever be one row returned I want to be able to to switch the column names to be row1 and the column values to be row 2 i.e. select house, street,...
2
1639
by: kimi | last post by:
Voip Learning and Translating Tutorial Voice Over IP is a new communication means that let you telephone with Internet at almost null cost. How this is possible, what systems are used, what is the standard, all that is covered by this Howto. http://www.freewebs.com/voipformula/VoIP-HOWTO.html
1
1099
by: MPA | last post by:
Hi, We are a small company with no experience in web development. We are considering translating our main client-server product into web application or web service using DOT.NET. Our app is basically a tree representing the employees and departments of our customers with some tabs where the corresponding info for each node is presented. Our customers have different databases (SQL Server, Sybase, Oracle), and that it why right now our...
1
1867
by: timn | last post by:
Translating Access SQL queries into SQL subqueries. -------------------------------------------------------------------------------- I have a query in Access that uses a subquery, I would like some help on translating it into SQL as a subquery so I can use it in an application. the queries in Access are the subquery... (query4) SELECT Movement.DateTime, Movement.StudentID, Movement.Subject, Movement.Teacher, Movement.Destination,...
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.