Bu soru defalarca soruldu ve defalarca yanıtladım ama sözle yanıtlamaktan daha ziyade yazmak ve göstermek tabiki daha kolay ve anlaşılır olacaktır bu sebeple
başlayalım hemen.
Önce Visual Studio'dan "Asp.Net Web Application" oluşturalım.
Arından bize bir adet label , bir adet textbox ve bir adet button ihtiyacımız var bunları sayfamıza yerleştirelim.Düzenli tutma için ben birde Panel ekledim ve içine yazdım nesnelerimi.
-------default.aspx Başı--------------------
<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="Default.aspx.cs" Inherits="AspToHTMLTest._Default" %>
<!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:Panel ID="Panel1" runat="server">
<asp:Label ID="lblcont" runat="server" Width="536px" Height="272px"></asp:Label>
<asp:TextBox ID="txtcode" runat="server" Width="400px" Height="272px"
TextMode="MultiLine"></asp:TextBox>
<asp:Button Id="btnsend" runat="server" Width="60px" Height="20px"
text="Oluştur"/>
</asp:Panel>
</div>
</form>
</body>
</html>
-------default.aspx Sonu--------------------
Ardından Code tarafmıza geçelim yani default.aspx.cs dosyamıza ve burda form'un load olayına button'un click eventini ekleyelim.Ardından Click event'in içindede textbox'a yazılan herşeyi label'e
gönderen kodumuzu yazalım.
-------default.aspx.cs başı-----------
using System;
using System .Collections .Generic;
using System .Linq;
using System .Web;
using System .Web .UI;
using System .Web .UI .WebControls;
namespace AspToHTMLTest
{
public partial class _Default : System .Web .UI .Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnsend .Click += new EventHandler(btnsend_Click);
}
void btnsend_Click(object sender, EventArgs e)
{
lblcont .Text = txtcode .Text;
}
}
}
--------default.aspx.cs sonu------------------
Burada dikkat etmemiz gereken nokta şudur.Asp.Net derlenirken böyle bir şeye izin vermez ve muhtemelen hata verecektir o yüzden eğer eklemediyseniz default.aspx sayfanızın başına
ValidateRequest="false" komutu eklemelisiniz ki Asp.Net bunu kontrol etmesin.
Basit ama işlevsel birşey birçok yerde kullanılabilir.Umarım işinie yarar.
| November 2009 | ||||||||||
| M | T | W | T | F | S | S | ||||
| 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 | ||||||||||
|
||||||||||