Note that there are some explanatory texts on larger screens.

plurals
  1. POC# to VB.Net Conversion Error
    text
    copied!<p>I have this piece of code where I'm trying to convert the below C# code to Vb.Net and place it in my content place holder and it gives me error as </p> <pre><code>Statement cannot appear outside of a method body/multiline lambda. </code></pre> <p>Can any one provide me the correct syntax.</p> <p>Here is the C# script:</p> <pre><code>&lt;script runat="server"&gt; [WebMethod()] public static bool CheckUserName(string userName) { return (Membership.GetUser(userName) != null); } &lt;/script&gt; </code></pre> <p>I'm using tangible converter and it's conversion to VB.Net is here:</p> <pre><code>&lt;script runat="server"&gt; (WebMethod()) public static Boolean CheckUserName(String userName) Return (Membership.GetUser(userName) IsNot Nothing) &lt;/script&gt; </code></pre> <p>And the entire code is here:</p> <pre><code>&lt;%@ Page Language="C#"%&gt; &lt;%@ Import Namespace="System.Web.Services" %&gt; &lt;%@ Import Namespace="System.Web.Security" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;script runat="server"&gt; [WebMethod()] public static bool CheckUserName(string userName) { return (Membership.GetUser(userName) != null); } &lt;/script&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Create User&lt;/title&gt; &lt;script type="text/javascript"&gt; var _txtUserName; var _divStatus; var _timerHandle; function pageLoad() { _txtUserName = $get('&lt;%= CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName").ClientID %&gt;'); _divStatus = $get('&lt;%= CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("divStatus").ClientID %&gt;'); $addHandler(_txtUserName, "keyup", onKeyUp); } function pageUnload() { $removeHandler(_txtUserName, "keyup", onKeyUp); clearTimer(); } function onKeyUp(e) { setupTimer(); } function setupTimer() { clearTimer(); _timerHandle = window.setTimeout(checkUserName, 500) } function clearTimer() { if (_timerHandle != null) { window.clearTimeout(_timerHandle); _timerHandle = null; } } function checkUserName() { if (_txtUserName.value.length &gt; 2) { _divStatus.innerHTML = 'Checking...'; _divStatus.style.color = 'black'; PageMethods.CheckUserName(_txtUserName.value, OnCheckUserNameComplete, OnCheckUserNameError, _txtUserName.value); } } function OnCheckUserNameComplete(result, userContext) { if (result == true) { _divStatus.innerHTML = String.format('\'{0}\' is already taken', userContext); _divStatus.style.color = 'red'; } else { _divStatus.innerHTML = String.format('\'{0}\' is available', userContext); _divStatus.style.color = 'green'; } } function OnCheckUserNameError(e) { _divStatus.innerHTML = e.get_message(); _divStatus.style.color = 'red'; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager ID="theScriptManager" runat="server" EnablePageMethods="true"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:CreateUserWizard ID="CreateUserWizard1" runat="server"&gt; &lt;WizardSteps&gt; &lt;asp:CreateUserWizardStep runat="server"&gt; &lt;ContentTemplate&gt; &lt;table border="0"&gt; &lt;tr&gt; &lt;td align="center" colspan="2"&gt;Sign Up for Your New Account&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"&gt;User Name:&lt;/asp:Label&gt;&lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="UserName" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;div id="divStatus" runat="server"&gt;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"&gt;Password:&lt;/asp:Label&gt;&lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="Password" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword"&gt;Confirm Password:&lt;/asp:Label&gt;&lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword" ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email"&gt;E-mail:&lt;/asp:Label&gt;&lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="Email" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question"&gt;Security Question:&lt;/asp:Label&gt;&lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="Question" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="QuestionRequired" runat="server" ControlToValidate="Question" ErrorMessage="Security question is required." ToolTip="Security question is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer"&gt;Security Answer:&lt;/asp:Label&gt;&lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="Answer" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="AnswerRequired" runat="server" ControlToValidate="Answer" ErrorMessage="Security answer is required." ToolTip="Security answer is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center" colspan="2"&gt; &lt;asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="CreateUserWizard1"&gt;&lt;/asp:CompareValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center" colspan="2" style="color: red"&gt; &lt;asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"&gt;&lt;/asp:Literal&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/ContentTemplate&gt; &lt;CustomNavigationTemplate&gt; &lt;table border="0" cellspacing="5" style="width: 100%; height: 100%;"&gt; &lt;tr align="right"&gt; &lt;td align="right" colspan="0"&gt; &lt;asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" Text="Create User" ValidationGroup="CreateUserWizard1" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/CustomNavigationTemplate&gt; &lt;/asp:CreateUserWizardStep&gt; &lt;asp:CompleteWizardStep runat="server"&gt; &lt;/asp:CompleteWizardStep&gt; &lt;/WizardSteps&gt; &lt;/asp:CreateUserWizard&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The original code is from <a href="http://geekswithblogs.net/rashid/archive/2007/06/30/Check-User-Name-in-Ajax-way.aspx" rel="nofollow">here</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload