I have a VBScript function in my ASP.net Page I have a small test function as shown below
<script type="text/vbscript">
sub testmePlease()
msgbox("Hello World")
end sub
</script>
I have a button in my webform and I am calling the function onclientclick as shown below
<asp:Button ID="btnAccept" runat="server" Text="Accept Settlement" OnClientClick="testmePlease()"/>
For some reason I get this end of statement expected javascipt error. What can be wrong??
I'm assuming you're using IE. Once Internet Explorer finds first <script> tag in your page, it assumes it's language as default.
Try this:
<script type="text/javascript">var foobar = false;</script>
<script type="text/vbscript">
sub testmePlease()
msgbox("Hello World")
end sub
</script>
And change your button to:
<asp:Button ID="btnAccept" runat="server"
Text="Accept Settlement"
OnClientClick="return testmePlease()"/>
Everything else should run ok.
Related
I have this problem. I was trying to build a spreasheet that, on open, would prompt a UI that allows the user to select between 3 custom buttons. A real scenerio would be this:
on open, it displays the message: "Hi! Which project do you wanna work on?" and, below this message, three buttons that say "Project 1", "Project 2" and "Project 3". Depending on the button pressed, It should modify the spreadsheet accordingly (for example, It would unify A1:A10 and write in it "Project 1" and so on).
How do I do this? Is this possible? Thanks:)
You can't do it to the Google Spreadsheet Ui because the button selections are fixed, OK, Cancel and such. But you can create a custom dialog.
In Code.gs I create an Installed onOpen
function myOnOpen(e) {
var html = HtmlService.createHtmlOutputFromFile("HTML_Simple");
SpreadsheetApp.getUi().showModalDialog(html,"Test");
}
Next I make a simple custom dialog with project buttons called HTML_Simple.html.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<p>Which project do you want to work on?</p>
<input id="project1" type="button" value="Project 1" onclick="clickProject(this)">
<input id="project2" type="button" value="Project 2" onclick="clickProject(this)">
<input id="project3" type="button" value="Project 3" onclick="clickProject(this)">
<script>
function clickProject(button) {
try {
alert("You picked "+button.id);
google.script.host.close();
}
catch(err) {
alert(err);
}
}
</script>
</body>
</html>
Now you can test the button id and branch to do whatever you want.
Reference
HTML Service
I have started to learn VBScript and I want to validate a HTML form / web page elements using VBScript .
Can anyone tell me if it is possible to refer an external HTML form/web page to the VBScript code and validate it's elements inside the script?
Like, I want to add a form reference or location (designed in HTML) in VBScript and validate its textbox, checkbox and submit it.
FYI, I can validate a HTML form simply by adding the VBScript part on the HTML code.
Example:
<html>
<head>
...
</head>
<body>
<script type="text/vbscript">
...
</SCRIPT>
<FORM NAME="Form1">
...
</FORM>
</body>
</html>
<HTML>
<HEAD><TITLE>Simple Validation</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Submit_OnClick
Dim TheForm
Set TheForm = Document.ValidForm
If IsNumeric(TheForm.Text1.Value) Then
If TheForm.Text1.Value < 1 Or TheForm.Text1.Value > 10 Then
MsgBox "Please enter a number between 1 and 10."
Else
MsgBox "Thank you."
End If
Else
MsgBox "Please enter a numeric value."
End If
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<H3>Simple Validation</H3><HR>
<FORM NAME="ValidForm">
Enter a value between 1 and 10:
<INPUT NAME="Text1" TYPE="TEXT" SIZE="2">
<INPUT NAME="Submit" TYPE="BUTTON" VALUE="Submit">
</FORM>
</BODY>
</HTML>
I want to validate a HTML form / web page elements using VBScript
This is very bad decision. Your solution will work only under Internet Explorer.
On client side strongly recomend to use JavaScript
On server sode of couse VBScript.
I have a telerik:RadCombobox in which user can type something to filter the recoreds.
If user type some word and tabout from taht control or clicked anywhere else on the form, basically onblur , its selectedindexedchanged event is fired that I don't want.
Please advise.
I have following html code on my page:
<telerik:RadComboBox ID="RCBGlobalSearch" runat="server" Height="190px" Width="330px"
EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
OnClientDropDownClosed="OnClientDropDownClosed" MarkFirstMatch="false" Filter="None"
HighlightTemplatedItems="true" Style="z-index: 9000" OnSelectedIndexChanged="RCBGlobalSearch_SelectedIndexChanged"
AutoPostBack="true" ToolTip="Enter or Select Issuer or User for Search">
<ExpandAnimation Type="none" />
<CollapseAnimation Type="none" />
<WebServiceSettings Path="~\GlobalSearchWebService.asmx" Method="GetGlobalSearchResult" />
</telerik:RadComboBox>
http://www.telerik.com/help/aspnet-ajax/combobox-onclienttextchange.html
- set_cancel lets you prevent the combobox from doing a postback (if AutoPostBack property is True), but doesn't let you prevent the text from changing.
<script language="javascript" type="text/javascript">
function OnClientTextChange(sender, eventArgs) {
eventArgs.set_cancel(true);
}
</script>
<telerik:RadComboBox onclienttextchange="OnClientTextChange"....
I`m newbie in jquery.
Got the following code:
`` `
How do I validate the textbox for user input required on clicking the button save and display error message next to the save button?
There appears to be a Validation Plug-In for jQuery. Have you looked at this already?
If not, it appears to do exactly what you want, and there is plenty of documentation right there to get started.
You can try something like
<html>
<head>
<script type="text/javascript">
function Test(txtCheck, lblCheck)
{
if (txtCheck.value == "")
lblCheck.innerHTML = "Textbox is empty";
else
lblCheck.innerHTML = "";
}
</script>
</head>
<body>
<input type="text" id="txtCheck" />
<input type="button" value="Save" onclick="Test(txtCheck, lblCheck);"/>
<label id="lblCheck"/>
</body>
The specific of the project is in using Enterpise Library for Server side validation and jQuery for client-side validation. So I have the next simple form for example:
<asp:Content ID="_mainContent" ContentPlaceHolderID="MainContent" runat="server">
<script src="../../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="../../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#aspnetForm").validate({
rules: {
"<%= _txtProjectName.UniqueID %>": {
required: true
}
}
});
});
</script>
<asp:TextBox ID="_txtProjectName" runat="server" CssClass="textBoxWithValidator_long" />
<entlib:PropertyProxyValidator id="_validatorProjectName" runat="server" ControlToValidate="_txtProjectName"
PropertyName="ProjectName" SourceTypeName="LabManagement.Project.Project" />
<asp:Button CssClass="cell_InlineElement" ID="_btnSave" runat="server" Text="Save" onclick="_btnSave_Click"
Width="50px" />
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
</asp:Content>
The problem is in the next: client-side validation worked correctly before I needed to implement some AJAX.NET feature. So I have to add to the page ScriptManager (the last two lines in the code). But after that the next situation appeared:
In InternetExplorer((7) - only in IE !!! - in Firefox everything works correctly) after clicking save button, if left the textbox ProjectName empty the client-side jquery validation appears but (!) the page submits to the server anyway.
Some notes:
If delete PropertyProxyValidator from the page - the client-side validation works correctly in IE but I need it for specific of the project.
It seems that the problem is in the function WebForm_OnSubmit() that is inserted to the form after PropertyProxyValidator adding. ( ... <form name="aspnetForm" method="post" action="Project.aspx?TransType=NewProject" onsubmit="javascript:return WebForm_OnSubmit();" ...>)
Could anyone help, please.
Just in case someone else comes across this issue, upgrade jQuery to 1.4.2. This will fix this bug.