473,473 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

issue with popualting a message on asp:label server control

hi all

i have a problem on populating a message on asp:label server control.I
am able to insert records into the table.but it is not populating any
message like "Records entered successfully". i wanted to implement
this .how to proceed can anybody tell me about this . i am using
asp.net/vb.net 2.0

here i am providing the code also:-

vb code:-

Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As
EventArgs)
If Page.IsPostBack = True Then

Dim dbcon As SqlConnection
dbcon = New SqlConnection("Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HRISD B.mdf;Integrated
Security=True;User Instance=True")
Dim dbcom As New SqlCommand()
dbcom.Connection = dbcon
dbcom.CommandType = CommandType.Text
dbcom.CommandText = "Insert into
TalentTeam(TalentTeamName) values(@TalentTeamName)"
dbcom.Parameters.Add("@TalentTeamName", SqlDbType.VarChar)

dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text.ToString()

If txtRecruiterName.Text.Length = 0 Then
dbcom.Parameters("@TalentTeamName").Value =
System.DBNull.Value
Else
dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text
End If

Try

dbcon.Open()
dbcom.ExecuteNonQuery()
lblMessage.Visible = "True"
txtRecruiterName.Text = ""
Dim result As Integer
result = dbcom.ExecuteNonQuery()

If result = 0 Then
lblMessage.Text = "Record not entered
successfully"
Else
lblMessage.Text = "Record entered successfully"
End If
Catch ex As Exception
Response.Write(ex.Message)
Response.End()
Finally
If dbcon.State = ConnectionState.Open Then
dbcon.Close()
End If
End Try
Response.Redirect("~/AddForms/addRecruiter.aspx")
Else
lblMessage.Text = "Please enter Recruiter Name"

End If

End Sub

..aspx code :-

<table>

<tr>
<td>
<asp:Panel ID="PanelEffectiveDate"
runat="server" >
<table>
<tr>
<td
align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;
<asp:Label
ID="lblAddRecruiter" runat="server" Text="Recruiter Name" ></
asp:Label>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;
</td>
<td align="right">
<asp:TextBox
ID="txtRecruiterName" runat="server" Text="" ></asp:TextBox>

<asp:RequiredFieldValidator ID="rfvEnterRecruiterName" runat="server"
ControlToValidate="txtRecruiterName" ErrorMessage="Plase Enter
Recruiter Name"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="3" align="right">
<asp:Button ID="btnAdd"
runat="server" Text="ADD" OnClick="btnAdd_Click" />

</td>
</tr>
<tr>
<td colspan="2"
align="center">
<asp:Label ID="lblMessage"
runat="server" Font-Bold="true" ForeColor="blue" ></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
please help me know to solve this issue.
Thanks in advance
Dhananjay
Dec 12 '07 #1
1 1366
You are asking a question about ASP.NET using VB.NET language in the C#
language newsgroup. Post it at the ASP.NET group:

http://msdn.microsoft.com/newsgroups...&lang=en&cr=US
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Dhananjay" wrote:
hi all

i have a problem on populating a message on asp:label server control.I
am able to insert records into the table.but it is not populating any
message like "Records entered successfully". i wanted to implement
this .how to proceed can anybody tell me about this . i am using
asp.net/vb.net 2.0

here i am providing the code also:-

vb code:-

Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As
EventArgs)
If Page.IsPostBack = True Then

Dim dbcon As SqlConnection
dbcon = New SqlConnection("Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HRISD B.mdf;Integrated
Security=True;User Instance=True")
Dim dbcom As New SqlCommand()
dbcom.Connection = dbcon
dbcom.CommandType = CommandType.Text
dbcom.CommandText = "Insert into
TalentTeam(TalentTeamName) values(@TalentTeamName)"
dbcom.Parameters.Add("@TalentTeamName", SqlDbType.VarChar)

dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text.ToString()

If txtRecruiterName.Text.Length = 0 Then
dbcom.Parameters("@TalentTeamName").Value =
System.DBNull.Value
Else
dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text
End If

Try

dbcon.Open()
dbcom.ExecuteNonQuery()
lblMessage.Visible = "True"
txtRecruiterName.Text = ""
Dim result As Integer
result = dbcom.ExecuteNonQuery()

If result = 0 Then
lblMessage.Text = "Record not entered
successfully"
Else
lblMessage.Text = "Record entered successfully"
End If
Catch ex As Exception
Response.Write(ex.Message)
Response.End()
Finally
If dbcon.State = ConnectionState.Open Then
dbcon.Close()
End If
End Try
Response.Redirect("~/AddForms/addRecruiter.aspx")
Else
lblMessage.Text = "Please enter Recruiter Name"

End If

End Sub

..aspx code :-

<table>

<tr>
<td>
<asp:Panel ID="PanelEffectiveDate"
runat="server" >
<table>
<tr>
<td
align="center">
<asp:Label
ID="lblAddRecruiter" runat="server" Text="Recruiter Name" ></
asp:Label>
</td>
<td align="right">
<asp:TextBox
ID="txtRecruiterName" runat="server" Text="" ></asp:TextBox>

<asp:RequiredFieldValidator ID="rfvEnterRecruiterName" runat="server"
ControlToValidate="txtRecruiterName" ErrorMessage="Plase Enter
Recruiter Name"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="3" align="right">
<asp:Button ID="btnAdd"
runat="server" Text="ADD" OnClick="btnAdd_Click" />

</td>
</tr>
<tr>
<td colspan="2"
align="center">
<asp:Label ID="lblMessage"
runat="server" Font-Bold="true" ForeColor="blue" ></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
please help me know to solve this issue.
Thanks in advance
Dhananjay
Dec 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the...
0
by: Dhananjay | last post by:
hi all i have a problem on populating a message on asp:label server control.I am able to insert records into the table.but it is not populating any message like "Records entered successfully"....
0
by: Dhananjay | last post by:
hi all i have a problem on populating a message on asp:label server control.I am able to insert records into the table.but it is not populating any message like "Records entered successfully"....
0
by: Dhananjay | last post by:
hi all i have a problem on populating a message on asp:label server control.I am able to insert records into the table.but it is not populating any message like "Records entered successfully"....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.