hello
I set the OnClick event in the GIS Module. Is it possible to prevent it to happen in client side.
I have a scenario where i want to postback when i click on the gis module some times (based on certain condition).For the moment i use the onclientclick to fire a postback (using __dopostback or click on a hidden button)
I would like to use the onclick event (server side event) to use the loading image embedded in the gis module while processing some action on the server side. But if i use the server side onclick event, the event is fired every time which i dont want.
thanks for your help
sebastien
On click event
Hi, sebastien
I don’t understand what do mean by saying that “I set the OnClick event in the GIS Module. Is it possible to prevent it to happen in client side.”
If you have registered the OnClick server-side event and undoubtedly it will always be triggered when you click on the map control. If really want to forbid it, the better choice is to consider using the OnClientClick client-side event with callback mechanism to reach your goal.
Or your first choice using the __dopostback with the OnClientClick is also as well.
I made one simple sample using callback technology to implement your requirements. If I misunderstand your meaning please correct me.
Thanks,
Khalil
UsingCallback.zip (2.34 KB)
some components propose to have an client side event : onclientclicking to prevent the serverside event onclick. Here is an example.
function onClientClicking(sender, eventArgs)
{
//prevent the postback to happen
eventArgs.set_cancel(true);
}
I hoped you had a similar feature.
sebastien
Hi, sebastien
I guess this feature has been provided by ASP.NET. In fact, you can register the OnClientClick and OnClick events at the same time, the OnClientClick event will be triggered firstly, and if it returns false and the OnClick event won’t be triggered. Please refer to the code below:
<html xmlns="w3.org/1999/xhtml">
<head runat="server">
<link href="~/theme/default/samplepic/style.css" rel="stylesheet" type="text/css" />
<title>Display a Simple Map</title>
<script type="text/javascript">
function OnClientClick(event) {
alert("OnClientClick");
// If you return false, execute no more callbacks that means the server-side click event won't be triggered,
// prevent the postback to happen
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:Map ID="Map1" runat="server" Width="100%" Height="100%" OnClick="Map1_Click" OnClientClick="OnClientClick">
</cc1:Map>
</form>
</body>
</html>
If you have additional questions please let us know.
Thanks,
Khalil