Oke Lets See screenshoot and code Below:
default.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="default.ascx.cs" Inherits="Module.ReadtxtFileSave._default" %>
<asp:UpdatePanel ID ="updatepanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td>Name
</td>
<td>:</td>
<td>
<asp:TextBox ID="txtnama" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Address
</td>
<td>:</td>
<td>
<asp:TextBox ID="txtAddress" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Hoby
</td>
<td>:</td>
<td>
<asp:TextBox ID="txthoby" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>gender
</td>
<td>:</td>
<td>
<asp:TextBox ID="txtgender" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td colspan ="3">
<asp:Button ID ="btnsave" runat ="server" Text ="SAVE" OnClick="btnsave_txtclick" />
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnsave" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
default.ascx.cs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Modules;
namespace Module.ReadtxtFileSave
{
public partial class _default : PortalModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsave_txtclick(object sender, EventArgs e)
{
try
{
var name = txtnama.Text;
var Address = txtAddress.Text;
var hoby = txthoby.Text;
var gender = txtgender.Text;
var userdata = name + "#" + Address + "#" + hoby + "#" + gender;
using (System.IO.StreamWriter file = new System.IO.StreamWriter(Server.MapPath("~/App_Data/simpanbiodata.txt"), true))
{
file.WriteLine(userdata);
}
}
catch (Exception)
{
}
txtnama.Text = "";
txtAddress.Text = "";
txtgender.Text = "";
txthoby.Text = "";
}
}
}
display result saving in txt file you can see screenshot this below
you can donload source code this link below
Tidak ada komentar:
Posting Komentar