link button client csript

S

Simon

I have linkButton:
<asp:LinkButton ID="lnkAddMedia" runat="server" CausesValidation="false"
Text="ADD media"></asp:LinkButton>

In code behind file(c#) I add a client script to this link button:
lnkAddMedia.OnClientClick="vbscript:selectMedia('1')";

When page is rendered, the rendered code is:

<a onclick="vbscript:selectMedia('1');"
id="ctl00_ContentPlaceHolder1_lnkAddMedia"
href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$lnkAddMedia','')">ADD
media</a>

and I get script error message on the page:
error: Expected end of statement

I guess that error is because of semicolon, which is added to my script:
vbscript:selectMedia('1');
(vbSCript doesn't have semicolons).

This semi colon was added automatically. How can I remove that?

One way is to put javascript instead of vbscript, but I preffer programming
in vbscript, because I have all program written in this language.


Thank you for your answers,
Simon
 
C

cbDevelopment

Why not use:

lnkaddmedia.attributes.add("onclick","vbscript:selectMedia(1)")

That shouldn't do any special formatting.

----
700cb Development, Inc.
http://www.700cb.net
..NET utilities, developer tools,
and enterprise solutions

I have linkButton:
<asp:LinkButton ID="lnkAddMedia" runat="server"
CausesValidation="false" Text="ADD media"></asp:LinkButton>

In code behind file(c#) I add a client script to this link button:
lnkAddMedia.OnClientClick="vbscript:selectMedia('1')";

When page is rendered, the rendered code is:

<a onclick="vbscript:selectMedia('1');"
id="ctl00_ContentPlaceHolder1_lnkAddMedia"
href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$lnkAddMedia','
')">ADD media</a>

and I get script error message on the page:
error: Expected end of statement

I guess that error is because of semicolon, which is added to my
script: vbscript:selectMedia('1');
(vbSCript doesn't have semicolons).

This semi colon was added automatically. How can I remove that?

One way is to put javascript instead of vbscript, but I preffer
programming in vbscript, because I have all program written in this
language.


Thank you for your answers,
Simon



--
 
S

SimonZ

Hi,

"lnkaddmedia.attributes.add" is obsolete - that is massage given by new
visual studio 2005.

So I use "lnkAddMedia.OnClientClick" - that is recomended method by VS2005.

But no matter which method I use, I always get the semicolon when the page
is rendered.

I don't know why?

So I rewrite my function to javascript but still I would like to know the
reason.

I have the latest Visual studio 2005 version: 8.0.50727.42, asp.net version:
2.0.50727 and project is in C# language.

Any idea?

Regards,S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top