Peter Chan
asked on
Problem to call the event
Hi,
Using these
BTW, how to also call one other event, whenever the mouse is "just" over the area of the iteure.
Using these
<div class="imagesList-item-frame shadow">
<img src="..." onclick="ite_click6" />
</div>
protected void ite_click6(object sender, EventArgs e)
{
...
but the event is not fired when I click the iteure on the page. why?BTW, how to also call one other event, whenever the mouse is "just" over the area of the iteure.
ASKER
Thanks. can I have the details to further call one code-behind event, within the javascript event below?
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
function event2() {
...
}
</script>
You can't just fire the event like that but you can call a method on your page via ajax for instance using jQuery.
What do you want to do when you call that server-side function?
What do you want to do when you call that server-side function?
ASKER
To further call one other .aspx page within another browser window.
call one other .aspx page within another browser windowWhat does this mean?
Open another page in a new window?
The basics of jQuery and AJAX are shown in this article. It uses PHP for the server side, but the principles would be equally applicable to any server-side scripting language.
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
greetings HuaMinChen, , I am not sure I understand what your problems are from what I can get reading through this. In your initial code you have -
<img src="..." onclick="ite_click6" />
so The EVENT you talk of is the user touching the image on their smart phone? ? is that right?
and you say you need to have this touch event open another tab in the phone browser that has a different asp page in it. I do not think that this needs any ajax, you just have to have your javascript ite_click6() function to do this? ?
but maybe I do not really see what the end result is for your touch-click event for this image?
<img src="..." onclick="ite_click6" />
so The EVENT you talk of is the user touching the image on their smart phone? ? is that right?
and you say you need to have this touch event open another tab in the phone browser that has a different asp page in it. I do not think that this needs any ajax, you just have to have your javascript ite_click6() function to do this? ?
but maybe I do not really see what the end result is for your touch-click event for this image?
just remembered, if you only need to open a new tab-window for an image you might try something like -
<a target="_blank" href="http://google.com" title="Google Search"><img src="googleIcon.jpg" /></a>
if you need to do more with some javascript variables or page elements, you can do an onclick function for the image
<a target="_blank" href="http://google.com" title="Google Search"><img src="googleIcon.jpg" /></a>
if you need to do more with some javascript variables or page elements, you can do an onclick function for the image
ASKER
Ray/Alexandre/Slick,
Like what I originally asked, I only want to see one sample, that is calling either one Ajax event or code-behind event, upon one click to the image on the page.
Like what I originally asked, I only want to see one sample, that is calling either one Ajax event or code-behind event, upon one click to the image on the page.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. Within the WebMethod, is it possible for me to further direct to one other page like
?
Response.Redirect("http://192.168.168.1/Showite/Default.aspx");
?
Not like that because you're not in the process of a page post-back.
What you can do is send the url as a reply to that ajax code and use window.location.href to perform the redirection on the client side.
What you can do is send the url as a reply to that ajax code and use window.location.href to perform the redirection on the client side.
public partial class _Default : Page
{
[WebMethod]
public static string DoMyStuff()
{
return "http://192.168.168.1/Showite/Default.aspx";
}
}
$.ajax({
type: "POST",
url: "PageName.aspx/DoMyStuff",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(resp) {
if(resp){
window.location.href=resp;
}
}
});
As a rough example it should work.
...I only want to see one sample, that is calling either one Ajax event or code-behind event, upon one click to the image on the page.That is exactly what you would have found if you had read the article linked here:
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
This is a very common question and you're not the first to ask! That's why we have an article system here at E-E. If you just make a search of the articles you will find many useful descriptions and examples for the most common programming questions.
Calm down Ray :)
Although the article is fine for client-side, the server-side "code" doesn't resemble at all to anything he needed to write to make it work in ASP.net. So in my opinion your bold italic whatever "exactly" is a bit off... :)
As the code client-side is the same, and if you really want to push it that hard for solutions, a good update to that article would be to add the .net version of it.
Cheers!
Although the article is fine for client-side, the server-side "code" doesn't resemble at all to anything he needed to write to make it work in ASP.net. So in my opinion your bold italic whatever "exactly" is a bit off... :)
As the code client-side is the same, and if you really want to push it that hard for solutions, a good update to that article would be to add the .net version of it.
Cheers!
That image element you have there is not a server-side control so it won't fire any server-side events.
Also, that onclick is expecting to find a javascript function called ite_click6 which you don't have.
So either handle the click on javascript or change the image element into a server-side control and handle the click with the proper OnClick server-side event.