Yday I faced a very strange problem
there is one user control who have a image button:
<input type='image' src=<URL of the image> onlick=removrrow(190,120)>
definition of removerow function was returning false.
<script>
function removerow(j,k)
{
...
...
return false;
}
</script>
Now the problem which was occurring was that when ever this image button gets clicked its was reloading the page. This image button was inside a usercontrol which loaded on a page which is opened inside a iframe which in turn is hosted on another page.
So this click was actually reloading the iframe which was opened on a click on another image button.
In order to stop this behavior I have returned false from removerow function since I have read in order to stop the page to submit or postback(you guessed it correct Asp.Net background) one can return false which I was already doing in this function but still it was reloading the iframe content.
My mind was gobbling arround what suddenly went wrong in this I tried lot of methods stoppropogation and cancelBubble= true but it was till posting the form.
In the end what I did I changed the way it was called from button click
Before: <input type='image' src=<URL of the image> onlick=removrrow(190,120);>
After: <input type='image' src=<URL of the image> onlick=javascript: return removrrow(190,120);>
And it worked. Yes putting return keyword as shown above made all the difference.
Happy Coding !!
there is one user control who have a image button:
<input type='image' src=<URL of the image> onlick=removrrow(190,120)>
definition of removerow function was returning false.
<script>
function removerow(j,k)
{
...
...
return false;
}
</script>
Now the problem which was occurring was that when ever this image button gets clicked its was reloading the page. This image button was inside a usercontrol which loaded on a page which is opened inside a iframe which in turn is hosted on another page.
So this click was actually reloading the iframe which was opened on a click on another image button.
In order to stop this behavior I have returned false from removerow function since I have read in order to stop the page to submit or postback(you guessed it correct Asp.Net background) one can return false which I was already doing in this function but still it was reloading the iframe content.
My mind was gobbling arround what suddenly went wrong in this I tried lot of methods stoppropogation and cancelBubble= true but it was till posting the form.
In the end what I did I changed the way it was called from button click
Before: <input type='image' src=<URL of the image> onlick=removrrow(190,120);>
After: <input type='image' src=<URL of the image> onlick=javascript: return removrrow(190,120);>
And it worked. Yes putting return keyword as shown above made all the difference.
Happy Coding !!
No comments:
Post a Comment