You created a "panel" (ie: <div>) and want to set or change the text within it using VB.NET (Visual Basic), but, there is no "text" property or method....What gives?
The trick is that you need to create a reference to the panel object as a "LiteralControl" and then set its "text" property.
Dim oPanel as LiteralControl
oPanel = CType(pnlText.Controls.Item(0),LiteralControl)
oPanel.text = "Hello Internet!"
"Cannot convert object of type 'System.String' to type 'System.String&'" "Cannot convert object of type 'System.String' to type 'System.Int32&'"
The key to decoding the source of this message is the "&" located in the end of the text. This is the syntax used when passing a parameter to a function BYREF (By-Reference). Note: This is the syntax used in C-Notation to indicate "pass the AddressOf" varname. Even if you coded the WebService in VB.NET, Microsoft will convert/compile it in C type notation when it outputs it as an assembly.
The problem/solution is that all parameter definitions for your WebMethod must passed BYVAL (By-VALUE). Check the procedure/webmethod definition for your WebSerice. It is probably has a paramater defined (incorrectly) as (ByRef pname as xxx).
When you add a control to an ASP.NET page using Visual Studio [Express] 2008 and give it an ID, this may NOT be the ID that appears in the HTML markup when the page is actually rendered.
However, when you run the page and look at the HTML markup/source in your browser, you find that the "#ID" of the control is NOT "txtemail". This is because Microsoft generates an #ID/name based on the ID you provide to the designer/IDE when it renders the page.
Because the VS 2008 may change the #ID of the control during page generation, attempting to reference or get a handle to the control using JavaScript and the control's "supposed" #ID of 'txtemail' may fail. The following MAY fail:
The trick is to force ASP.NET to substitute the actual #ID that the server generates to your JavaScript Code. You do this by using ASP.NET/VB.NET variable substitution to supply the "ClientID" of the control/element during page generation by the server. Use the following sytax in your javascript code:
This one ANNOYED me for the better part of a day! I had a simple login form with some asp:input (textbox) fields, and a couple of HoneyPot/Captcha fields to prevent BOTS/Spammers from submitting the form. Also on the form was a simple INPUT/SUBMIT button.
Some requiredfield validators were added to the page to force the user to enter thier login/password. Everything worked fine until I added my own JavaScript function to the "onclick" event of the submit button, intended to the validte HoneyPot/Captcha fields and prevent the form from being submitted if the fields were changed.
No matter how I adjusted the rfv's or the code in my validatePage() function, nothing worked right and the page constantly did a PostBack.
Force the MS client-side validation routines to run FIRST from within YOUR JavaScript/Validation function.
MY validation function is called: validateForm() To my submit button I added: onclick="return validateForm();"
In the code of my validateForm() function I added the following: (and everything ran fine...)
//Check the MS validations first!
if (Page_ClientValidate() == true) {
.... (run my code)
return false; //to prevent the page from being submitted
}