Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Saturday, March 31, 2012

Strange and annoying problem

Even commenting a line in javascript still prompts for an error. If I remove the following line then no error, but again if i put it back, even commented error occurs.

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

isn't it strange behavior

Yes it is strange. As far as i am aware of, there are three types of comment you can do in java:

1. Multiple-line :/* and*/

2.One-line comments of C++ style: Begins with // and continue up to the next line break:

3.One-line comments with theHTML comment-opening sequence (<!--). Note that the JavaScript interpreter ignores the closing characters of HTML comments (-->). Consider this example:
<!-- This is treated as a one-line JS comment<!-- It works just like a comment beginning with //<!-- --> This is also a one-line JS comment<!-- --> because JS ignores the closing characters<!-- --> of HTML-style comments

HTML-style comments are not usually found in the middle of JavaScript code. However, it is recommended to use HTML comments for hiding Javascript code from old browsers

Try using this mate


Hi,

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

Your comment in javascript doesn't stop<%=TextBox1.ClientID%> since it is asp.net code. So to clear the error you have to remove this code.


You have to comment the aspnet code also

if you are using C#

//opener.document.getElementById('<%/*=TextBox1.ClientID*/%>').value='akberalikaka';

if you are using VB

//opener.document.getElementById('<%'=TextBox1.ClientID'%>').value='akberalikaka';

<%'=TextBox1.ClientID'%> is equivalent to <% Response.Write(TextBox1.ClientID) %>

Monday, March 26, 2012

Strange error

Hello,

I'm getting an error "Invalid pointer" with a javascript in my code. The script was working just fine and I don't know what caused it to stop working. I'm executing the script in a button's click event handler, so I tried to execute instead a simple javascript:


private void Button1_Click(object sender, System.EventArgs e)

{
Response.Write("<script>alert('Hi');</script>");
}

I'm getting the same error!

what could be causing the problem?

ThanksThis isn't another of the wonderfull windows XP service pack 2 glitches is it?

http://msdn.microsoft.com/security/productinfo/XPSP2/default.aspx

Regards

Jeff
Hi Jeff,

no I haven't made any changes to my Windows XP instalation and at first the code was working fine. I made some changes to the code but nothing related to the javascript.

Regards
Hi again,

I found the answer in other threads, should have searched before I ask. The error ocurs after setting SmartNavigatoin to true.

It's great to have a place for getting help!

Thank you all !

Thursday, March 22, 2012

Strange HTML button postback

I have a webform with lots of <asp:...controls but I need couple of buttons
that doesn't cause an automatic postback. I use javascript to handle these
buttons. I tried two approaches with different results:

<IMG onmouseup="src='Bitmaps/Controls/measure_over.bmp';"
onmousedown="src='Bitmaps/Controls/measure_pressed.bmp';"
id="measure" onmouseover="src='Bitmaps/Controls/measure_over.bmp';"
style="LEFT: 170px; WIDTH: 24px; POSITION: absolute; TOP: 2px; HEIGHT: 25px"
onclick="buttonClicked(this.id);"
onmouseout="src='Bitmaps/Controls/measure_btn.bmp';"
alt="" src="http://pics.10026.com/?src=Bitmaps/Controls/measure_btn.bmp"
This is working the way I want to, but I can't disable it as I can with a
button. I then replace the IMG with:

INPUT Type="image"

and it makes a postback every time I click on it. Why? A HTML control
should't do that, right? The script itself (buttonClicked) just fills a
hidden field.

/MiroFrom the MSDN Library about the <input typ="image" tag:

------------------------
INPUT type=image Element | input type=image Object
Creates an image control that, when clicked, causes the form to be
immediately submitted.
------------------------

Maybe add "onclick='return false;'" to the tag.

-Jason Kendall
JasonKendall@.hotmail.com

On Tue, 1 Feb 2005 05:55:13 -0800, "Miro"
<Miro@.discussions.microsoft.com> wrote:

>I have a webform with lots of <asp:...controls but I need couple of buttons
>that doesn't cause an automatic postback. I use javascript to handle these
>buttons. I tried two approaches with different results:
><IMG onmouseup="src='Bitmaps/Controls/measure_over.bmp';"
>onmousedown="src='Bitmaps/Controls/measure_pressed.bmp';"
>id="measure" onmouseover="src='Bitmaps/Controls/measure_over.bmp';"
>style="LEFT: 170px; WIDTH: 24px; POSITION: absolute; TOP: 2px; HEIGHT: 25px"
>onclick="buttonClicked(this.id);"
>onmouseout="src='Bitmaps/Controls/measure_btn.bmp';"
>alt="" src="http://pics.10026.com/?src=Bitmaps/Controls/measure_btn.bmp">
>This is working the way I want to, but I can't disable it as I can with a
>button. I then replace the IMG with:
>INPUT Type="image"
>and it makes a postback every time I click on it. Why? A HTML control
>should't do that, right? The script itself (buttonClicked) just fills a
>hidden field.
>/Miro

Strange HTML button postback

I have a webform with lots of <asp:...controls but I need couple of buttons
that doesn't cause an automatic postback. I use javascript to handle these
buttons. I tried two approaches with different results:
<IMG onmouseup="src='Bitmaps/Controls/measure_over.bmp';"
onmousedown="src='Bitmaps/Controls/measure_pressed.bmp';"
id="measure" onmouseover="src='Bitmaps/Controls/measure_over.bmp';"
style="LEFT: 170px; WIDTH: 24px; POSITION: absolute; TOP: 2px; HEIGHT: 25px"
onclick="buttonClicked(this.id);"
onmouseout="src='Bitmaps/Controls/measure_btn.bmp';"
alt="" src="http://pics.10026.com/?src=Bitmaps/Controls/measure_btn.bmp">
This is working the way I want to, but I can't disable it as I can with a
button. I then replace the IMG with:
INPUT Type="image"
and it makes a postback every time I click on it. Why? A HTML control
should't do that, right? The script itself (buttonClicked) just fills a
hidden field.
/MiroFrom the MSDN Library about the <input typ="image" tag:
----
--
INPUT type=image Element | input type=image Object
Creates an image control that, when clicked, causes the form to be
immediately submitted.
----
--
Maybe add "onclick='return false;'" to the tag.
-Jason Kendall
JasonKendall@.hotmail.com
On Tue, 1 Feb 2005 05:55:13 -0800, "Miro"
<Miro@.discussions.microsoft.com> wrote:

>I have a webform with lots of <asp:...controls but I need couple of buttons
>that doesn't cause an automatic postback. I use javascript to handle these
>buttons. I tried two approaches with different results:
><IMG onmouseup="src='Bitmaps/Controls/measure_over.bmp';"
>onmousedown="src='Bitmaps/Controls/measure_pressed.bmp';"
>id="measure" onmouseover="src='Bitmaps/Controls/measure_over.bmp';"
>style="LEFT: 170px; WIDTH: 24px; POSITION: absolute; TOP: 2px; HEIGHT: 25px
"
>onclick="buttonClicked(this.id);"
>onmouseout="src='Bitmaps/Controls/measure_btn.bmp';"
>alt="" src="http://pics.10026.com/?src=Bitmaps/Controls/measure_btn.bmp">
>This is working the way I want to, but I can't disable it as I can with a
>button. I then replace the IMG with:
>INPUT Type="image"
>and it makes a postback every time I click on it. Why? A HTML control
>should't do that, right? The script itself (buttonClicked) just fills a
>hidden field.
>/Miro

Strange Javascript Cookie Behaviour

Hi folks,

Been looking at this for the day so any ideas would be appreciated. Here's
the scenario, bear with me - it looks more complicated than it is :)

I have a page templating system that inherits from the page class and adds a
mixture of usercontrols and literals when requested.

One of the usercontrols is a menu that expands on being clicked using DHTML.
What I'm trying to do is to persist the expanded menu to other pages or
accross page refreshes so that if a user expands the menu for a menu item on
one page it will be rendered on the following page as expanded for that same
menu item.

As the id of the span needs to be stored when it's clicked I figured that
the easiest way to accomplish this would be to set and pass the id of the
expanded menu item (a <span> element) in a cookie using javascript and then
check for the existence of this cookie and use it's value to expand the menu
using the onLoad attribute of the body tag on the new page.

The cookie is not persisted accross sessions - i.e. no expiry date is set. I
have not set the path either.

At the start of a new session on entering the first page of the site the
function checks the cookie, see's that it doesn't exist yet (as a menu item
hasn't been clicked/expanded yet) and the page simply loads.

On the first page I have established using alert boxes that when I click the
menu item/span the correct id is being being returned to an alert box set to
catch the onclick event and then the cookie is successfully set to the value
of the span id as I use an alert box to return the value of the cookie after
it's set. This works for all menu items.

when I navigate to another page an alert box displaying the cookie value
indicates that the cookie has been successfully persisted and the correct
span is expanded.

However, if I then click on other spans in the menu, the alert box that
displays the id of the span I have clicked returns the correct value and the
span expands, the following line of javascript set's the cookie supposedly
using this span id but in the next line of code producing the second alert
box reading the cookie, the alert box shows that the cookie has been set to
the original span id and not the one I actually clicked. This is confirmed
when I navigate to another page as the original span id is in the cookie and
that span is expanded.

Anyone got any ideas what's going on here???

Looking forward to hearing your ideas,

Bewildered JoeOk, I am officially dumb - it was a path problem - this dumbass takes a bow
;)

"Joe" <info@.hyper-typer.com> wrote in message
news:OykZ3D5uDHA.2880@.tk2msftngp13.phx.gbl...
> Hi folks,
> Been looking at this for the day so any ideas would be appreciated. Here's
> the scenario, bear with me - it looks more complicated than it is :)
> I have a page templating system that inherits from the page class and adds
a
> mixture of usercontrols and literals when requested.
> One of the usercontrols is a menu that expands on being clicked using
DHTML.
> What I'm trying to do is to persist the expanded menu to other pages or
> accross page refreshes so that if a user expands the menu for a menu item
on
> one page it will be rendered on the following page as expanded for that
same
> menu item.
> As the id of the span needs to be stored when it's clicked I figured that
> the easiest way to accomplish this would be to set and pass the id of the
> expanded menu item (a <span> element) in a cookie using javascript and
then
> check for the existence of this cookie and use it's value to expand the
menu
> using the onLoad attribute of the body tag on the new page.
> The cookie is not persisted accross sessions - i.e. no expiry date is set.
I
> have not set the path either.
> At the start of a new session on entering the first page of the site the
> function checks the cookie, see's that it doesn't exist yet (as a menu
item
> hasn't been clicked/expanded yet) and the page simply loads.
> On the first page I have established using alert boxes that when I click
the
> menu item/span the correct id is being being returned to an alert box set
to
> catch the onclick event and then the cookie is successfully set to the
value
> of the span id as I use an alert box to return the value of the cookie
after
> it's set. This works for all menu items.
> when I navigate to another page an alert box displaying the cookie value
> indicates that the cookie has been successfully persisted and the correct
> span is expanded.
> However, if I then click on other spans in the menu, the alert box that
> displays the id of the span I have clicked returns the correct value and
the
> span expands, the following line of javascript set's the cookie supposedly
> using this span id but in the next line of code producing the second alert
> box reading the cookie, the alert box shows that the cookie has been set
to
> the original span id and not the one I actually clicked. This is
confirmed
> when I navigate to another page as the original span id is in the cookie
and
> that span is expanded.
> Anyone got any ideas what's going on here???
> Looking forward to hearing your ideas,
> Bewildered Joe