<%@ Page Language="VB" MaintainScrollPositionOnPostback="true" AutoEventWireup="false" CodeFile="Default5.aspx.vb" Inherits="Default5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<%
' scrpt x utitlizzo JQuery
%>
<script src="./JQuery/jquery-2.1.1.min.js" type="text/javascript"></script>
<%
' scrpt JQuery solo numeri su casella di testo txtQuantita del gridview
%>
<script type="text/javascript">
function CheckNumericValue(e) {
var key = e.which ? e.which : e.keyCode;
//enter key //backspace //tabkey //escape key
if ((key >= 48 && key <= 57) || key == 13 || key == 8 || key == 9 || key == 27) {
return true;
}
else {
alert("Inserire solo NUMERI");
return false;
}
}
</script>
<script type="text/javascript">
function somma() {
alert("La somma è 5");
}
</script>
<%
' scrpt che abilita l'invio sulle caselle di testo
%>
<script type="text/javascript">
$(document).ready(function () {
$('input:text:first').focus();
$('input:text').bind("keydown", function (e) {
var n = $("input:text").length;
if (e.which == 13) { //Enter key
e.preventDefault(); //to skip default behavior of the enter key
var nextIndex = $('input:text').index(this) + 1;
if (nextIndex < n)
$('input:text')[nextIndex].focus();
else {
$('input:text')[nextIndex - 1].blur();
$('#Button1').focus()
}
}
});
});
</script>
<%
' scrpt che COLORA LO SFONDO DELLE caselle di testo quando mi ci posiziono sopra
%>
<script type="text/javascript">
$(document).ready(function () {
$("input:text").focus(function () {
$(this).css("background-color", "#CCFFFF");
});
$("input:text").blur(function () {
$(this).css("background-color", "#ffffff");
});
});
</script>
<%
' scrpt che colora le label dei button al passaggio del mouse
%>
<script type="text/javascript">
var previousColor;
function MakeRed() {
previousColor = window.event.srcElement.style.color;
window.event.srcElement.style.color = "#FF0000";
}
function RestoreColor() {
window.event.srcElement.style.color = previousColor;
}
</script>
<%
' scrpt che visualizza messaggio "inserire solo numeri" --> aggiungere onkeyup="ValidateText(this)" su ItemTemplate
'<script type="text/javascript">
' function ValidateText(val) {
' var intValue = parseInt(val.value, 10);
' if (isNaN(intValue)) {
' alert("inserire solo numeri");
' }
'}
'</script>
%>
<%
' funzine colara di verde una riga in JQuery
%>
<script type="text/javascript">
function mioJquery() {
$('p:contains("3")').css("color", "Green");
}
</script>
<%
' scrpt JQuery solo numeri su casella di testo TextBox2 (non funge in campo di gridview)
%>
<script type="text/javascript">
$(document).ready(function () {
$("#TextBox2").keydown(function (e) {
if (e.shiftKey) e.preventDefault();
else {
var nKeyCode = e.keyCode;
//Ignore Backspace and Tab keys
if (nKeyCode == 8 || nKeyCode == 9) return;
if (nKeyCode < 95) {
if (nKeyCode < 48 || nKeyCode > 57) e.preventDefault();
} else {
if (nKeyCode < 96 || nKeyCode > 105) e.preventDefault();
}
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView2" runat="server" AllowSorting="True" AutoGenerateColumns="False" Width="169px" AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None" Height="221px">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:Label ID="id" runat="server" Text='<%# Bind("id")%>'
AutoPostBack="false"
Width="40">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="nome">
<ItemTemplate>
<asp:Label ID="nome" runat="server" Text='<%# Bind("nome")%>'
AutoPostBack="false"
Width="100">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Copie DL">
<ItemTemplate>
<asp:Label ID="copie" runat="server" Text='<%# Bind("copie")%>'
AutoPostBack="false"
Width="40">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Copie PDV">
<ItemTemplate>
<asp:TextBox runat="server" ID="arrivo" Text='<%# Bind("arrivo")%>' Width="70"
ToolTip="Digitare le copie arrivate"
onkeypress="return CheckNumericValue(event)"
AutoPostBack="true"
OnTextChanged="arrivo_TextChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="M/E">
<ItemTemplate>
<asp:Label runat="server" ID="mancecc" Text='<%# Bind("mancecc")%>' Width="70"
ToolTip="Mancanze/Eccedenze">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Riferimento">
<ItemTemplate>
<asp:TextBox runat="server" ID="riferimento" Text='<%# Bind("riferimento")%>' Width="200"
ToolTip="Campo riferimento">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<br />
<asp:Button ID="Button2" runat="server" Height="50px" Text="Button" Width="173px" onmouseover="MakeRed();" onmouseout="RestoreColor();" />
<br />
<br />
<asp:Button ID="Button1" runat="server" Height="40px" Text="Submit" Width="246px" onmouseover="MakeRed();" onmouseout="RestoreColor();" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Width="414px"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Width="414px" style="background-color: #FFFFFF"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" Width="414px" CssClass=".number"></asp:TextBox>
</div>
<p>Questo è il Paragarfo 1</p>
<p>Questo è il Paragarfo 2</p>
<p>Questo è il Paragarfo 3</p>
<p>Questo è il Paragarfo 4</p>
<br />
<br />
<input id="btn_esempio" type="button" name="Jquery" title="Jquery" value="ProvaJQuery" onclick="mioJquery()" />
</form>
</body>
</html>
Protected Sub arrivo_TextChanged(sender As Object, e As EventArgs)
Dim row As GridViewRow = DirectCast(DirectCast(sender, TextBox).NamingContainer, GridViewRow)
Dim copie As Label = DirectCast(row.FindControl("copie"), Label)
Dim arrivo As TextBox = DirectCast(row.FindControl("arrivo"), TextBox)
Dim mancecc As Label = DirectCast(row.FindControl("mancecc"), Label)
If arrivo IsNot Nothing And copie IsNot Nothing Then
mancecc.Text = CInt(arrivo.Text) - CInt(copie.Text)
End If
End Sub