...

View Full Version : New at aspx programming



Philosophaie
07-03-2012, 03:49 AM
New at aspx programming.

In PHP:

<?php
code
?>

How do you program in a .aspx program to get things started?

Is it only in xml or can you program directly from a Visual Basic program?

I want to access mysql databases:

<?php
$conn = mysql_connect('localhost', 'user', 'pass');
mysql_select_db('db1');
$sqls = "UPDATE `register` SET security=1764 WHERE idr=3";
$results = mysql_query($sqls, $conn);
mysql_close($conn);
?>

alykins
07-03-2012, 12:26 PM
from my understanding of php, it is more like ASP than aspx... aspx usually utilizes (and IMO should) the code behind files.

A 'sample' aspx page might have a look like so...


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lbl_Demo" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="txt_Demo" runat="server"></asp:TextBox>
<asp:Button ID="btn_Demo" runat="server" Text="Button"
onclick="btn_Demo_Click" />
</div>
</form>
</body>
</html>


and then the code behind...


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lbl_Demo.Text = "Sample 1";
txt_Demo.Text = "";
}
}

protected void btn_Demo_Click(object sender, EventArgs e)
{
lbl_Demo.Text = txt_Demo.Text;
txt_Demo.Text = "";
}
}
}


and it would render as...







<!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><title>



</title></head>

<body>

<form method="post" action="WebForm1.aspx" id="form1">

<div class="aspNetHidden">

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEzMTc4NjY3NTgPZBYCAgMPZBYCAgEPDxYCHgRUZXh0BQhTYW1wbGUgMWRkZJt1FGwftAzSw6Btk7luA4ajsvpQP8rnb jcBqI0SP3jH" />

</div>



<div class="aspNetHidden">



<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKVyP+aCALBztLIBgLZgJeUDWvmV3gm2pPl2jKIzfQLsY0a5YHNRBF1m4XrlxO+BAv2" />

</div>

<div>

<span id="lbl_Demo">Sample 1</span>

<input name="txt_Demo" type="text" id="txt_Demo" />

<input type="submit" name="btn_Demo" value="Button" id="btn_Demo" />

</div>

</form>

</body>

</html>


so as you can see... very different than php or ASP



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum