User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,421 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,527 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting

LinkButton1 code fires only on the second click

Join Date: Feb 2008
Posts: 8
Reputation: namsSoftee is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
namsSoftee namsSoftee is offline Offline
Newbie Poster

Re: LinkButton1 code fires only on the second click

  #3  
Feb 27th, 2008
HI


Thanks for your reply . Iam new to dotnet. Can you tell me clearly what has to be added where ?
I added
LinkButton1.Attributes.Add("onclick", " alert('\nYou have already taken this test');")
in the page_load event and also i made the change as shown below

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
sql = "select LS from Tests_Attended where Emp_ID = " & Session("EmpID")
cmd = New OleDbCommand(sql, con)
ds = cmd.ExecuteReader
If ds.HasRows = True Then
ds.Read()
If ds.Item("LS") = True Then
LinkButton1.Attributes.Add("onclick", " alert('\nYou have already taken this test');return false;") Else
sql = "update Tests_Attended set LS = 1 where Emp_ID= " & Session("EmpID")
cmd = New OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
Server.Transfer("opener1.aspx")
End If
Else
sql = "insert into Tests_Attended values(" & Session("EmpID") & ",1,0,0,0)"
cmd = New OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
Server.Transfer("opener1.aspx")
End If
End Sub

It works in the first click now but it works both if if-condition passes or fails.

Please modify the code & show me regarding what has to be added where.

Thanks
Nams Here...
Reply With Quote  
All times are GMT -4. The time now is 5:12 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC