before we go code C# we has to table in sqlserver.folow step by step below this.
Open your SQLSERVER 2008
Open you database and make Table For Example.Name Table is TNAMA .at below you can see!
if you has make table above you go in visual studio 2008 or visual studio 2012.
Open your visual studio 2008 and new project.
name project example is default.ascx and default.ascx.cs
content for default.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="default.ascx.cs" Inherits="Module.InsertData._default" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
<table>
<tr>
<td>
NAMA IMPUTAN:
</td>
<td>
<asp:TextBox ID="txtNama" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<td>
<asp:Label ID="lblDuplicate" runat="server" ForeColor="Red" Text="" Visible ="false"></asp:Label>
</td>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnsimpan" runat="server" OnClick ="btnsimpan_click" Text ="SIMPAN" />
</td>
</tr>
</table>
.
and we can see example code c# above for this
and then we make code for default.ascx.cs for below this to save in table.
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;
using System.Data.SqlClient;
using System.Configuration;
namespace Module.InsertData
{
public partial class _default : PortalModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsimpan_click(object sender, EventArgs e)
{
try
{
FormRegisterSolution.Entitas.TNAMA OBJADA = new FormRegisterSolution.Entitas.TNAMA();
OBJADA = new FormRegisterSolution.Controler.Controltestname().TNAMALIST.Where(s => s.Nama.Equals(txtNama.Text)).FirstOrDefault();
if(txtNama.Text==OBJADA.Nama)
{
lblDuplicate.Visible = true;
lblDuplicate.Text="Nama yang masukan exixst";
}
else
{
OBJADA.Nama = txtNama.Text;
FormRegisterSolution.Controler.Controltestname ctlr=new FormRegisterSolution.Controler.Controltestname();
ctlr.addnama(OBJADA);
}
}
catch (Exception ex)
{
}
}
}
}
and result if you imput content and ever you imput before then validation aktif.this below screenshoot.
.
oKE thank You.