Click here to Skip to main content
15,886,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi coder i have a hyperlink in my grid-view when user click on that link it will redirect to another page. this is my hyperlink code:

C#
<asp:HyperLinkField DataNavigateUrlFields="ID"
               DataNavigateUrlFormatString="~/User/Form.aspx?ID={0}&buttonValue=Update"
               HeaderText="Query" NavigateUrl="~/User/Form.aspx" Text="Select"/>



what i want is when user click on it second time it won't work. How can i do that

Thanks in advance
Posted
Comments
Dholakiya Ankit 6-Sep-13 6:44am    
onclick="this.disable='false'";

This might help you out:

Disable link after click
 
Share this answer
 
Using Jquery
C#
$(document).ready(function(){
  $('.button').click(function(){
    $('.button').click(function(e) {
      e.preventDefault();

    });
  }
}



this may help.
 
Share this answer
 
Comments
amitesh1989 6-Sep-13 8:28am    
@gitnajali please take a look at my comment at the bottom of this you will get the overall scenario of my application
Hi,

When user click on the link you are redirect user to another page so you need to keep the clicked link information somewhere. You have also not mention if you want to keep that information for particular user or for particular session only.

If you want it to keep that information for user wise, you need to store that information somewhere in the database. and at the time of loading grid you need to disable/enable the link based on the value stored in the database.

In case of session based information, you need to store clicked link information somewhere in session/Cookies.

Hope this will works for you.

Thanks
-Amit Gajjar
 
Share this answer
 
Comments
amitesh1989 6-Sep-13 6:56am    
it is hyperlinkfield not hyperlink. See in this application i have a form where user fill that form and press submit button and details save in the database
User can view this details inside a grid-view with a select link to edit details when user click on that hyperlink it will redirect back to form page where submit button convert into Update button using DataNavigateUrlFormatString="~/User/Form.aspx?ID={0}&buttonValue=Update"
now i guess u understand my question
AmitGajjar 6-Sep-13 7:26am    
ok, in that case you need to keep that state in the database.
amitesh1989 6-Sep-13 8:23am    
how??
can you explain with an example
Try:
C#
onclick="this.disable='false'";
 
Share this answer
 
v3
Comments
amitesh1989 6-Sep-13 8:24am    
there is no onclick event in hyperlinkfield
Finally got my answer

I add a bit datatype in my database so that when user enter details in form and press submit button bit become "true" and when click on link and update details bit become "false" when bit become false write code on RowDataBoung

C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        string url = DataBinder.Eval(e.Row.DataItem, "Bit").ToString();
        if (url =="False")
        {
            e.Row.Cells[15].Enabled = false;
        }
    }
}
 
Share this answer
 

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