Hi all:
I have a page with fields that hooks up to a stored procedure.
[code--vb]
Protected Sub bAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bAdd.Click
If Not IsPostBack Then
Dim s As New clsADO
Dim SB As New System.Text.StringBuilder
SB.Append(s.UserID & ", '")
SB.Append(tFirst.Text & "', '")
SB.Append(tLast.Text & "', '")
SB.Append(tAdd1.Text & "', '")
SB.Append(tAdd2.Text & "', '")
SB.Append(tCity.Text & "', '")
SB.Append(ddState0.Text & "', '")
If Len(tZip.Text) < 10 Then
tZip.Text &= "00000"
End If
SB.Append(tZip.Text & "', '")
SB.Append(tEMail.Text & "', '")
SB.Append(tPhone1.Text & "', '")
SB.Append(tPhone2.Text & "'")
s.RunSQL("SP_InsertEMail " & SB.ToString)
lMsg.Text = "1 Record Added"
End If
End Sub
[/code]
[code--ASPX]
<asp:Button ID="bAdd" runat="server" BackColor="#CCFFFF" BorderColor="#CCFFFF"
OnClick="bAdd_Click" Text="Add" Width="92px" />
[/code]
It works, but it's inserting twice...my guess was on postback, which is why I tossed in the If Not IsPostBack statement. Once I did that, I get nothing.
I can easily add a boolean to make sure it only fires once, but what is the proper way?
I'd really like to learn this, and I get a curve with each new pitch.
Thanks,
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors
I have a page with fields that hooks up to a stored procedure.
[code--vb]
Protected Sub bAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bAdd.Click
If Not IsPostBack Then
Dim s As New clsADO
Dim SB As New System.Text.StringBuilder
SB.Append(s.UserID & ", '")
SB.Append(tFirst.Text & "', '")
SB.Append(tLast.Text & "', '")
SB.Append(tAdd1.Text & "', '")
SB.Append(tAdd2.Text & "', '")
SB.Append(tCity.Text & "', '")
SB.Append(ddState0.Text & "', '")
If Len(tZip.Text) < 10 Then
tZip.Text &= "00000"
End If
SB.Append(tZip.Text & "', '")
SB.Append(tEMail.Text & "', '")
SB.Append(tPhone1.Text & "', '")
SB.Append(tPhone2.Text & "'")
s.RunSQL("SP_InsertEMail " & SB.ToString)
lMsg.Text = "1 Record Added"
End If
End Sub
[/code]
[code--ASPX]
<asp:Button ID="bAdd" runat="server" BackColor="#CCFFFF" BorderColor="#CCFFFF"
OnClick="bAdd_Click" Text="Add" Width="92px" />
[/code]
It works, but it's inserting twice...my guess was on postback, which is why I tossed in the If Not IsPostBack statement. Once I did that, I get nothing.
I can easily add a boolean to make sure it only fires once, but what is the proper way?
I'd really like to learn this, and I get a curve with each new pitch.
Thanks,
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors