Re: I don't get javascript. How do you use it?
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Sat, 24 Mar 2007 19:24:06 +0100
Tony Girgenti wrote:
Hello Mark and Mark.
I tried it both Mark Fitzpatrick's way and Mark Rae's way. Either way does not give an error, but it does not do anything.
<input id="Button1" style="z-index: 103; left: 496px; position: absolute; top: 392px"
type="button" value="button" onClick="ShowCal;" />
<asp:Button ID="Button2" runat="server" Style="z-index: 104; left: 688px; position: absolute; top: 392px" Text="Button" onClientClick="ShowCal();" />
When i click Button1, it does nothing and puts an "Error on page" on the bottom of the IE screen and does nothing.
Then it creates an error message, you just haven't enabled displaying of error messages in the browser. The default in the browser is to not display error messages other than as the notification in the status bar, to protect regular users from getting error message popups whenever there is some bad code in a page.
The reason for the error message is that there is no "Style" property of the input element, the correct name is "style". Also you are trying to read the z property from it and subtracting the index variable, and noone of those exists. In script you use zIndex to access the z-index style, as a variable name can not contains a dash.
Look at the code in my other post.
When i click Button2, i can see the progress bar at the bottom of the IE screen, but it does nothing.
That is because the client script has errors, and the event code doesn't contain return false; to prevent the button from making a postback. An asp:Button control will be rendered as a input with tyep="submit", so it will always make a postback unless you prevent it.
Thanks,
Tony
"Mark Rae" <mark@xxxxxxxxxxxxxxxxx> wrote in message news:uKWUbTjbHHA.4888@xxxxxxxxxxxxxxxxxxxxxxx"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message news:OfTZE7ibHHA.2300@xxxxxxxxxxxxxxxxxxxxxxx
I tried some javascript testing in VS2005, SP1, VB , .NET 2.0, ASP.NET 2.0 on WIN XP Pro, SP2.Because you're not calling it... The OnClick event of an <asp:Button> will cause the page to post back (unless you're using AJAX or something similar) and try to run a server-side method...
It's real simple. I put a button on a page and coded the onClick in it like this:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px; position: absolute; top: 392px" Text="Button" OnClick="ShowCal" />
Here is the function:
<script type="text/javascript" language="javascript">
function ShowCal() {
var x = Button1.Style.z - index;
alert(x);
}
</script>
It won't let me run the program saying "'ShowCal' is not a member of 'ASP.default_aspx'"
If javascript is so popular, why can't i use it?
Change your code to the following:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px; position: absolute; top: 392px" Text="Button" OnClientClick="ShowCal();" />
--
Göran Andersson
_____
http://www.guffa.com
.
- References:
- I don't get javascript. How do you use it?
- From: Tony Girgenti
- Re: I don't get javascript. How do you use it?
- From: Mark Rae
- Re: I don't get javascript. How do you use it?
- From: Tony Girgenti
- I don't get javascript. How do you use it?
- Prev by Date: Re: Dynamic Listbox in Gridview
- Next by Date: Re: Problems With Custom RoleProvider and Forms Authentication
- Previous by thread: Re: I don't get javascript. How do you use it?
- Next by thread: Re: I don't get javascript. How do you use it?
- Index(es):