locked
How to perform both a OnClick and DblOnClick event on a text string RRS feed

  • Question

  • User1909155429 posted

    I currently have a Linkbutton that posts back to server both CommandName and Argument values. I want to first run javascript code to display Div content on click then able to post back to server on dblclick. This is not possible with LinkButton as i have discovered.So is there another alternative method?

    <asp:LinkButton ID="LinkButton1" OnClientClick="updateParameter2(this);return false;"   CommandArgument='<%#DataBinder.Eval(Container, "DataItem.MessageID")%>' CommandName="Messages"    runat="server"><%#DataBinder.Eval(Container,"DataItem.Subject")%></asp:LinkButton> 
    

    Monday, March 1, 2021 8:47 PM

Answers

  • User1535942433 posted

    Hi peterthegreat,

    According to your description, I think you don't use linkbutton. You could only use javascript to perform Onclick and DblOnclick. You could click and  do a postback in javascript. And then, you could write a DblOnclick event in javascript.

    By the way,double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser.

    So I think it's better if you reconsider your actual UI using only one click event and other controls to handle your needs; eg on the click handler open a menu with the possible actions.

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 11, 2021 6:11 AM

All replies

  • User-1545767719 posted

    I currently have a Linkbutton that posts back to server both CommandName and Argument values.

    This is "ASP.NET Core" forum. You are talking about the LinkButton server control of ASP.NET Web Forms which is not supported by ASP.NET Core.

    Tuesday, March 2, 2021 1:31 AM
  • User1535942433 posted

    Hi peterthegreat,

    According to your description,I think your problem is "return false".

    I suggest you could remove "return false".If "return false" is execute then it would never submit and OnClick(which is sever side would never executed).

    Best regards,

    Yijing Sun

    Wednesday, March 3, 2021 9:06 AM
  • User1909155429 posted

    it still does not operate a double click event? i instead used two controls to perform operation.one on  client, other server side.

    Sunday, March 7, 2021 8:51 PM
  • User1535942433 posted

    Hi peterthegreat,

    it still does not operate a double click event?

    I don't understand your reuqirment clearly.Double click? I have created a demo using onclick and onclientclick together on a linkbutton. Just like this:

     <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="javascript:return overshowusermessage(event, this);" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
    

    Best regards,

    Yijing Sun

    Tuesday, March 9, 2021 6:59 AM
  • User1909155429 posted

    using that approach both events will occur on one click event unless cancel  where i wanted to click once to open a div using javascript and again to run server side code.

    Similar on the same subject of Linkbutton click events, how is it possible to open and close a div or hide and show a adjacent element to the link inside same table cell <td> when inside repeater control? i manage to open but not close on same link click event?

    Wednesday, March 10, 2021 8:10 PM
  • User1535942433 posted

    Hi peterthegreat,

    According to your description, I think you don't use linkbutton. You could only use javascript to perform Onclick and DblOnclick. You could click and  do a postback in javascript. And then, you could write a DblOnclick event in javascript.

    By the way,double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser.

    So I think it's better if you reconsider your actual UI using only one click event and other controls to handle your needs; eg on the click handler open a menu with the possible actions.

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 11, 2021 6:11 AM