I am working on a project and I need to be able to call a java script function when double clicking on a image. So far, for testing, I was using the On Click function and it was working perfectly, but now that I added the "Double" work it doesn't seem to work.
Please see below the code on the asp image:
<asp:Image href="#" ID="MapImage" runat="server" Height="601px" Width="469px" OnDoubleClick="javascript:MapImage_Click()"/>
This is the java script function code:
function MapImage_Click() {
alert('hello');
}
Do anyone have any idea why this is happening?
Thanks!
Use ondblclick instead of OnDoubleClick.
Correct code would be <asp:Image href="#" ID="MapImage" runat="server" Height="601px" Width="469px" ondblclick="javascript:MapImage_Click()"/>
Try ondblclick="MapImage_Click();"
Related
I've added a HyperLink control to a GridView within a TemplateField and I want it to redirect the user to a specific page, passing the ID from the selected row. The following works just fine:
<asp:HyperLink ID="hlViewBasketItem" runat="server" Text="Detail"
NavigateUrl='<%# Eval("BasketItemID", "/BasketItemDetail.aspx?popUp=true&id={0}") %>'>
</asp:HyperLink>
The ID evaluates correctly; for example: "/BasketItemDetail.aspx?popUp=true&id=52"
The problem I have is that I need to make a call to a Javascript function to control the display of my page (so that it appears within a popup). I've tried the following:
<asp:HyperLink ID="hlViewBasketItem" runat="server" Text="Detail"
NavigateUrl='<%# Eval("BasketItemID", "javascript:dnnModal.show('/BasketItemDetail.aspx?bid={0}&popUp=true',false,550,950,false)") %>'>
</asp:HyperLink>
...but I'm getting a "server tag is not well formed" error.
Is there a actually a way to do this?
This was the answer:
NavigateUrl=<%# "Javascript:dnnModal.show('BasketItemDetail.aspx?popUp=true&bid=" + DataBinder.Eval(Container.DataItem, "BasketItemID").ToString() + "')"%>
I can go to bed now :)
rather than using asp.net hyperlink add use html anchor tag and call java script function as follows:
//javascript function
<script>
function openPop(drp) {
window.open('/BasketItemDetail.aspx?bid='+drp+'&popUp=true', false, 550, 950, false);
}
</script>
// Anchor tag
Click Here
My project is an asp.net project and i have a separate page named "Districting", and it's called from an iframe.
In Districting.aspx page, there is a function that fires a .click() event for a button:
The button clicked by the user:
<button id="b1" onclick="DoneClicked();">Done</button>
The function is:
function DoneClicked(){
$("#button1").click();
}
button1 is the id of an asp button, which calls a function from the server side:
<asp:Button id="button1" cssClass="invisiblebutton" OnClick="AddingDistrict" runat="server" />
The cssClass, invisiblebutton contains the property: display:none.
The problem is that $("#button1").click() event is not working only in IE, so it's not calling the function AddingDistrict() from cs page.
It is working fine in chrome and FireFox.
Can anyone help me about this issue?
Thanks in advance:)
Perhaps javascript in ie is disabled
check it
I have a navigation bar consisting of list items. Right at the end of the nav bar I want a logout link:
//other links
...
<li>
logout
</li>
I have an event in my C# code called Logout_Click(object sender, EventArgs e) that I want to run when the user clicks the above navbar link, but obviously ordinary <a> tags don't trigger ASP.NET click events.
So I thought I'd be clever and create a HIDDEN <asp:Button> called logout that does trigger the Logout_Click function, and then get the JavaScript to click the button for me.. here is my code:
Log Out
<form runat="server">
<asp:Button ID="logout" runat="server" onclick="Logout_Click" Visible="false" />
</form>
But it still didn't work.
Can someone help me?
Try:
Log Out
Can you try without the Visible="false" on the asp:button?
And if it works hide it with css instead, style="display:none;"
I think the script needs the client side id of your asp.net control:
javascript:document.getElementById('<%=logout.ClientID').click()
Or you can use the __doPostBack function ...
http://wiki.asp.net/page.aspx/1082/dopostback-function/enter link description here
Why not you are using Asp.net LinkButton ?
It's easy to do this work with LinkButton.
In SharePoint I am trying to create a link that pops up a window
<a id="Z5" href="javascript:popUp('<% $SPUrl:~site/Pages/Mine.aspx%>')" runat="server" style="text-decoration:none;color:#000000">Mine</a>
But when I use that code i get a link with exactly javascript:popUp('<% $SPUrl:~site/Pages/Mine.aspx%>)' in my page how can I use the SPUrl and still have a javascript popup any ideas?
I ended up switched my link to
<a id="Z5" href="javascript:popUp()" runat="server" style="text-decoration:none;color:#000000">Mine</a>
Then changed my JS to
window.open("<asp:Literal runat="server" Text="<%$SPUrl:~site/pages/Mine.aspx%>" />"
and it worked.
hi I have an asp button which is created using the following code:
<asp:Button ID="btnBack" OnClientClick='javascript:history.back()' runat="server" Text="back">
</asp:Button>
However, now the javascript doesn't work to go a history back. On the other hand, if I make an alert() it works...why. Why is it not working to go a history back?
Try with return false at end:
<asp:button id="btnBack" runat="server" text="Back"
OnClientClick="JavaScript: window.history.back(1); return false;"></asp:button>
Try:
parent.history.back();
Or
history.go(-1)
Had the same problem in DevExpress project. Using ASPxButton without initializing the property "AutoPostBack" will result in redirect to self page before any client-side function call.
Try AutoPostBack="false" for the button.