473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem when generating Client Side Script.

I use in Render( HtmlTextWriter output) :

//--------------------------------------------------------------------------

output.WriteBeginTag( "a" );

if( ID != null )

output.WriteAttribute( "id", ClientID );
output.WriteAttribute( "href", "javascript:" +
Page.GetPostBackEventReference( this ) );

output.Write( HtmlTextWriter.TagRightChar );

if( Text.Length > 0 )

output.Write( Text );

output.WriteEndTag( "a" );

//--------------------------------------------------------------------------
-------------------------

This creates the HTML:

<a id="WebLinkButtonCtrl1"
href="javascript:__doPostBack('WebLinkButtonCtrl1' ,'')">Type something
here</a>

The problem is when I press the button as it gives a:

Microsoft JScript runtime error: Object expected

Does anyone have any ideas as how to solve this as it appears to be
happening whenever I use

output.WriteAttribute( "href", "javascript:" +
Page.GetPostBackEventReference( this ) );

even when they are copied from samples etc.

Thanks

John.
Nov 17 '05 #1
2 2642
It was because the control wasn't inside the form tag.

Does anyone know why this is the case?

"John Owens" <jo****@vision.com> wrote in message
news:ed**************@tk2msftngp13.phx.gbl...
I use in Render( HtmlTextWriter output) :

//--------------------------------------------------------------------------
output.WriteBeginTag( "a" );

if( ID != null )

output.WriteAttribute( "id", ClientID );
output.WriteAttribute( "href", "javascript:" +
Page.GetPostBackEventReference( this ) );

output.Write( HtmlTextWriter.TagRightChar );

if( Text.Length > 0 )

output.Write( Text );

output.WriteEndTag( "a" );

//-------------------------------------------------------------------------- -------------------------

This creates the HTML:

<a id="WebLinkButtonCtrl1"
href="javascript:__doPostBack('WebLinkButtonCtrl1' ,'')">Type something
here</a>

The problem is when I press the button as it gives a:

Microsoft JScript runtime error: Object expected

Does anyone have any ideas as how to solve this as it appears to be
happening whenever I use

output.WriteAttribute( "href", "javascript:" +
Page.GetPostBackEventReference( this ) );

even when they are copied from samples etc.

Thanks

John.

Nov 17 '05 #2
Hi,

I haven't check your code, but one thing I can be sure of, the controls
should be inside a form.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"John Owens" <jo****@vision.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
It was because the control wasn't inside the form tag.

Does anyone know why this is the case?

"John Owens" <jo****@vision.com> wrote in message
news:ed**************@tk2msftngp13.phx.gbl...
I use in Render( HtmlTextWriter output) :

//--------------------------------------------------------------------------

output.WriteBeginTag( "a" );

if( ID != null )

output.WriteAttribute( "id", ClientID );
output.WriteAttribute( "href", "javascript:" +
Page.GetPostBackEventReference( this ) );

output.Write( HtmlTextWriter.TagRightChar );

if( Text.Length > 0 )

output.Write( Text );

output.WriteEndTag( "a" );

//--------------------------------------------------------------------------
-------------------------

This creates the HTML:

<a id="WebLinkButtonCtrl1"
href="javascript:__doPostBack('WebLinkButtonCtrl1' ,'')">Type something
here</a>

The problem is when I press the button as it gives a:

Microsoft JScript runtime error: Object expected

Does anyone have any ideas as how to solve this as it appears to be
happening whenever I use

output.WriteAttribute( "href", "javascript:" +
Page.GetPostBackEventReference( this ) );

even when they are copied from samples etc.

Thanks

John.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
4
by: scott cooper | last post by:
I hope this illustrates my question a little better. Consider the following script; why does the client side script change the div object's innerHtml property but the server side script does not?...
3
by: Brian | last post by:
Hi I'm trying to get a small script working I need to get the user to input some info from a prompt and then use that info in a PHP script, but I can't seem to assign the JavaScript var to a...
13
by: nobody | last post by:
Hello all, I've searched just about everything and although I can see that other people are having problems, but theirs don't seem to relate, so in a last ditch attempt, my posting! Script...
2
by: Guadala Harry | last post by:
In an aspx file I have declared a hidden field like this: <input id="hTestVal" type=hidden value="-1" runat="server"> Defined in the code-behind like this: protected...
21
by: Phil Powell | last post by:
<script type=\"text/javascript\"> <!-- var browserArray = new Array(\"Microsoft Internet Explorer\", \"Netscape\"); if (browserArray.in_array(navigator.appName, browserArray) &&...
5
by: bspittles | last post by:
Can anyone tell me why the following script doesn't work in Firefox 1.5 (not sure about other versions) when it works fine in IE6 and Netscapes 7.1? Almost as importantly ;) can ayone tell me how...
7
by: Alex Maghen | last post by:
I have some client-side JavaScript that I want to run whenever a pulldown <SELECT> is changes on th client. I'm trying to do this as follows... <select id="MyPulldown"...
102
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem...
9
by: djconner | last post by:
I'm a total neophyte in Javascript, trying to hack something together fast, and run into something that I can't understand at all. Two loops appear in sequence. The idea is that arrQuestions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.