ecrire le code Webform1.aspx.cs dans Webform1.aspx?
Bonjour,
j´aimerai savoir si c´est possible d´ecrire le code Webform1.aspx.cs dans le code Webform1.aspx?
si c´est possible, svp comment ecrire ce code.
j´aimerais ecrire mon code Webform1.aspx.cs suivant dans le code Webform1.aspx afin que toute la compilation et le resultat soit faite juste dans le code webform1.aspx
voila le code Webform1.aspx.cs
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using System.Reflection;
namespace VersuchAsp3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Bind Gridview
//BindGvData();
// Bind Charts
BindChart();
}
}
private void BindGvData()
{
gvData.DataSource = GetChartData();
gvData.DataBind();
}
private void BindChart()
{
DataTable dsChartData = new DataTable();
StringBuilder strScript = new StringBuilder();
try
{
dsChartData = GetChartData();
strScript.Append(@"<script type='text/javascript'>
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type='text/javascript'>
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['Datum', 'FirstInProductionDate', ],");
foreach (DataRow row in dsChartData.Rows)
{
//row["Datum"] = DateTime.Parse(String.Format("{0}:dd.MM.yyyy", row["Datum"]));
var datetime = new DateTime();
if (DateTime.TryParse(row["Datum"].ToString(), out datetime))
{
var d = datetime.ToString("MM/dd/yyyy");
row["Datum"] = d;
strScript.Append("['" + d + "'," + row["FirstInProductionDate"] + "," + row["FirstDownloadBtnIOSDate"] + "],");
}
}
strScript.Remove(strScript.Length - 1, 1);
strScript.Append("]);");
strScript.Append
("var options = { title : 'Chart_Ansicht_Infos',isStacked: true, vAxis: {title: 'Anzahl', titleTextStyle: {fontName: 'Arial Black', fontSize:'14'}, viewWindow: {min:'0', max:'400',}};");
strScript.Append(" var chart = new google.visualization.ComboChart(document.getElementById('chart_div')); chart.draw(data, options); } google.setOnLoadCallback(drawVisualization);");
strScript.Append("
</script>");
ltScripts.Text = strScript.ToString();
}
catch (Exception ex)
{
}
finally
{
dsChartData.Dispose();
strScript.Clear();
}
}
private DataTable GetChartData()
{
DataSet dsData = new DataSet();
try
{
SqlConnection sqlCon = new SqlConnection(@"server=sql3; database=BarForce; Trusted_Connection=yes; connection timeout=120");
SqlCommand command5 = new SqlCommand("command12", sqlCon);
SqlDataAdapter sqlCmd = new SqlDataAdapter(command5);
//sqlCmd.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlCon.Open();
sqlCmd.Fill(dsData);
sqlCon.Close();
}
catch
{
throw;
}
}
} |
voila le code Webform1.aspx
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="VersuchAsp3.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%--<head runat="server">
<title>Charts Example</title>
</head--%>>
<body>
<%--<form id="form1" runat="server">--%>
<div>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<asp:GridView ID="gvData" runat="server" >
</asp:GridView>
<asp:boundfield datafield="gvData" HeaderText ="gvdata" dataformatstring="{0:dd-MM-yyyy}" htmlencode="false" />
<br />
<br />
<asp:Literal ID="ltScripts" runat="server"></asp:Literal>
<div id="chart_div" style="width: 800px; height: 600px;">
</div>
</div>
<%-- </form> --%>
</body>
</html>
</asp:content>
<asp:Content ID="Content4" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="MainContent" runat="server">
<div id="chart_div" style="width: 660px; height: 400px;">
</div>
</asp:Content> |
Merci d´avance