문제

I'm working on an asp.net c# empty web forms project. I have a SQL Server Compact database with a single table that I want to use to store information about an elements (x,y) coordinates.

The database should be updated with the new coordinates for a particular panel when the mouseup event is triggered on that panel (a div essentially). The solution doesn't need to be ajax, submitting the page will be ok.

The problem is that there is no mouseup type of event for an <asp:Panel> element and on the other side I'm not sure how I would trigger something server-side from jQuery. Getting the coordinates using jQuery is easy enough, but what would I do from there?

Are hidden inputs ok for this? Give me your best solution - I don't need to see code, just give me a better idea of what i should be doing.

Thanks!

도움이 되었습니까?

해결책

First check what exactly asp:Panel is getting rendered in browser by firebug, suppose it renders as div then you can use jquery's .mouseup() function and bind this event to what ever element that panel is rendered. Suppose if that asp:panel is rendered as div then look this below code for sample.

 <div id="asp_panel">
  Click here
</div>
$('#asp_panel').mouseup(function() {

    $.ajax({
            url: "HelloWorld.asmx/Hello",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            data: "{}", // if your method takes any parameter pass it in here in json format.
            dataType: "JSON"
            success: function(msg) {
                alert(msg);
            }
    });
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top