0
When I took the example of the site worked, but when I include a new Webform and in a new project and paste the codes of the codebehind example in VB.net and the aspx code does not work, gives the warning message, I made some adaptations in the collection of 3 points to make it easier to run the example. Some days I try. Can you help? Uso visualstudio Express 2017
aspx code:
<%@ Page Title="" Language="vb" AutoEventWireup="false"
MasterPageFile="~/Site.Master" CodeBehind="teste1.aspx.vb"
Inherits="SIIv3.teste1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
</script>
<script type="text/javascript">
$(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'teste1.aspx/GetDadosGrafico',
data: '{}',
success:
function (response) {
drawchart(response.d);
},
error: function () {
alert("Issue to load Data.");
}
});
})
function drawchart(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Name');
data.addColumn('number', 'Column Value');
for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].Silos, dataValues[i].Total]);
}
new google.visualization.PieChart(document.getElementById('chartdiv')).
draw(data, { title: "JcmSoft - Participação Mercado por País" });
}
</script>
<div id="chartdiv" style="width: 590px; height: 201px;">
</div>
</asp:Content>
VB.net codebehind
Imports System.Web.Services
Partial Class teste1
Inherits Page
<WebMethod>
Public Shared Function GetDadosGrafico() As List(Of DadosDetalhes)
Dim listaDados As New List(Of DadosDetalhes)()
Dim details As New DadosDetalhes With {
.Silos = "silo",
.Total = 13
}
listaDados.Add(details)
details = New DadosDetalhes With {
.Silos = "silo1",
.Total = 20
}
listaDados.Add(details)
details = New DadosDetalhes With {
.Silos = "silo2",
.Total = 5
}
listaDados.Add(details)
Return listaDados
End Function
End Class
Public Class DadosDetalhes
Public Property Silos() As String
Public Property Total() As Integer
End Class
If you’re starting the project, and it’s not big. I recommend you move on to using ASP.NET Core Razor Pages or ASP.NET MVC, because ASP.NET Webforms is already " deprecated" and will no longer receive updates with news.
– Vinícius Lima
thank you, I’ll try.
– Roberto Luiz Teixeira Rocha
If you only use
visual basic
, then study about theMVC
, forRazor Pages
supports only C#.– Vinícius Lima
I researched about your suggestion, but I found very complex the use of MVC, we must have a very high knowledge for creating controllers, views, tasks and etc... My project is very simple. I will basically use gridview and some charts collecting oracle BD data, which is why I opted for Asp.net. Do you have any suggestions on how to create webforms for IIS simply by dragging the components? I appreciate your help.
– Roberto Luiz Teixeira Rocha
If you are using Visual Studio, when you open a file
.aspx
, right after the code, below. It has 3 buttons, you can click on "Design" and do the same way you do with Windows Forms: See here an example image.– Vinícius Lima
good evening, I decided to program in Asp.net mvc as per your tip. At first it was difficult, but I’m getting the morning. thanks for the tip.
– Roberto Luiz Teixeira Rocha
Good, congratulations! It’s hard even at the beginning, I had enough difficulty, but it’s worth it :)
– Vinícius Lima