<table width="450px" border="0" cellspacing="0" cellpadding="3" align="center">
<tr>
<td valign="top" class="text" align="center" >
<asp:Label ID="Label1" runat="server" Text="empname"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:TextBox ID="txtempname" runat="server" Height="22px"></asp:TextBox>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
<asp:Label ID="Label2" runat="server" Text="eno"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:TextBox ID="txteno" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
<asp:Label ID="Label3" runat="server" Text="startdate"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:Calendar ID="empcalstartdate" runat="server"></asp:Calendar>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
</td>
<td valign="top" class="text" align="center">
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
<asp:Label ID="lblds" runat="server" Text="Your details submitted"
Visible="False"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:Button ID="Submit" runat="server" BorderStyle="Solid" Text="Submit"
onclick="Submit_Click" />
<asp:Button ID="btngraph" runat="server" BorderStyle="Solid" Text="Display graph"
onclick="Submit_Click" Visible="False" />
</td>
</tr>
</table>
protected void Submit_Click(object sender, EventArgs e)
{
//string empty1 = string.Empty;
//empty1 = txtempname.Text;
//string empty2 = string.Empty;
//empty1 = txteno.Text;
//string empty3 = string.Empty;
//empty1 = empcalstartdate.SelectedDate.ToString();
if (txtempname.Text.Length == 0 || txteno.Text.Length == 0)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please type your User ID and Password correctly and click Submit button again. Thanks", true);
}
else
{
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Employeeinformations"];
web.AllowUnsafeUpdates = true;
SPListItemCollection coll = list.Items;
SPListItem item = coll.Add();
item["empname"] = txtempname.Text;
// string txtnostring = txteno.Text;
//int m = Int32.Parse("txtno");
item["eno"] = txteno.Text;
item["empjoineddate"] = empcalstartdate.SelectedDate;
web.AllowUnsafeUpdates = false;
lblds.Visible = true;
item.Update();
list.Update();
lblds.Text = string.Empty;
txtempname.Text = string.Empty;
txteno.Text = string.Empty;
btngraph.Visible = true;
string seldt = empcalstartdate.SelectedDate.ToString();
seldt = string.Empty;
}
}
<tr>
<td valign="top" class="text" align="center" >
<asp:Label ID="Label1" runat="server" Text="empname"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:TextBox ID="txtempname" runat="server" Height="22px"></asp:TextBox>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
<asp:Label ID="Label2" runat="server" Text="eno"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:TextBox ID="txteno" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
<asp:Label ID="Label3" runat="server" Text="startdate"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:Calendar ID="empcalstartdate" runat="server"></asp:Calendar>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
</td>
<td valign="top" class="text" align="center">
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
<asp:Label ID="lblds" runat="server" Text="Your details submitted"
Visible="False"></asp:Label>
</td>
<td valign="top" class="text" align="center">
<asp:Button ID="Submit" runat="server" BorderStyle="Solid" Text="Submit"
onclick="Submit_Click" />
<asp:Button ID="btngraph" runat="server" BorderStyle="Solid" Text="Display graph"
onclick="Submit_Click" Visible="False" />
</td>
</tr>
</table>
protected void Submit_Click(object sender, EventArgs e)
{
//string empty1 = string.Empty;
//empty1 = txtempname.Text;
//string empty2 = string.Empty;
//empty1 = txteno.Text;
//string empty3 = string.Empty;
//empty1 = empcalstartdate.SelectedDate.ToString();
if (txtempname.Text.Length == 0 || txteno.Text.Length == 0)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please type your User ID and Password correctly and click Submit button again. Thanks", true);
}
else
{
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Employeeinformations"];
web.AllowUnsafeUpdates = true;
SPListItemCollection coll = list.Items;
SPListItem item = coll.Add();
item["empname"] = txtempname.Text;
// string txtnostring = txteno.Text;
//int m = Int32.Parse("txtno");
item["eno"] = txteno.Text;
item["empjoineddate"] = empcalstartdate.SelectedDate;
web.AllowUnsafeUpdates = false;
lblds.Visible = true;
item.Update();
list.Update();
lblds.Text = string.Empty;
txtempname.Text = string.Empty;
txteno.Text = string.Empty;
btngraph.Visible = true;
string seldt = empcalstartdate.SelectedDate.ToString();
seldt = string.Empty;
}
}
No comments:
Post a Comment