Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello..........

I have One Link Button.
On client click of this link button i am showing a message to the user via javascript.
But i want to update values in the database on click of the same button as well.
(e.g. I want to run counter on that ")
But the problem is that whole thing is happening in <asp:repeater> control.
so When i am going to click on button Client side function executes but IT does not go
in the "Itemcommand" of the Repeater control.
Suggest me if u have any ideas


Thanks in advance.......
Posted
Updated 31-Oct-11 2:19am
v2
Comments
AswinKrishnan 24-Oct-11 8:55am    
you gonna show message first and then call the function ? or the Vice versa ?
Ramkesh Banwala 31-Oct-11 5:10am    
Yes i wanna Message First and then Increment in Database

 
Share this answer
 
v3
Hi,

Add this as your Link Button.

ASP.NET
<asp:LinkButton ID="LinkButtonTest" runat="server" 
            OnClientClick="javascript:alert('Hi');" onclick="LinkButtonTest_Click">Testing


and this as your code behind.

C#
protected void LinkButtonTest_Click(object sender, EventArgs e){
            // code here.
}


you can add a javascript function in OnClientClick event to show any message.
 
Share this answer
 
1. Return true from your javascript function, then server side will be fired
2. u can use
__doPostBack('" + UniqueIDWithDollars(ctrl) + @"','');
to force fully call postback
 
Share this answer
 
Hi ,

ON load event paste the below code.

When user will click the button ,he/she will be prompted . I have used this code in the row databound event of gridview and rest i leave it upto you.
C#
linkbutton1.Attributes.Add("onclick", "javascript:return " +
   "confirm('Are you sure you want to delete this record " +
     DataBinder.Eval(e.Row.DataItem,"ID_OF_Record") + "')");


Regards,
Kishor
 
Share this answer
 
v2
Try this:

1: Html
ASP.NET
<asp:linkbutton id="lnkButton" runate="server" OnClick="lnkButton_Click" OnClientClick="return DisplayMessage();">Click Me!


2: Javascript
JavaScript
function DisplayMessage()
{
    //message to be displayed to user goes here
    var response = true;//you can return false to prevent server-side code from being executed!
    return response;
}


3. CodeBehind
C#
protected void lnkButton_Click( object sender, EventArgs e )
{
   //whatever you want to do on server-side
}


Happy coding,
Morgs
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900