473,385 Members | 1,838 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,385 software developers and data experts.

How do I include a server tag within a javascript parameter which is itself within a HTML element event?

How do I include a server tag within a javascript parameter which is
itself within a HTML element event.

For instance no matter what permutation of quotes I try here I get
errors on this line:

<asp:ImageButton ID="cmdDeleteLogin" runat="server"
SkinID="DeleteButton" CommandName="DeleteLogin"
CommandArgument='<%# Eval("LoginID") %>'
OnClientClick =
'return confirm(Are you certain you want to delete: <%#
Eval("UserName") %>)' />

I want the final code to look something like this:

<input type="image"
name="ctl00$ContentPlaceHolder$repLogins$ctl01$cmd EditLogin"
id="ctl00_ContentPlaceHolder_repLogins_ctl01_cmdEd itLogin"
src="../App_Themes/SomeSite_Admin/images/edit_button.gif"
onclick="return confirm('Are you certain you want to delete: Joe
Doe');"
style="border-width:0px;" />

Clearly the problem is that double quotes can't be used to enclose <%#
Eval("UserName") %but I need to enclose the argument to the
javascript confirm function in qutoes.

I found out what the problem was here
<http://blogs.clearscreen.com/ragc/archive/2004/10/28/525.aspxbut
there's no clue as to what the solution might be.

Nov 6 '06 #1
2 3372
Mark,

At first glance it looks like you're missing some single quotes (or
quotes around your confirm() call. The text is not wrapped!

If that doesn't yeild any results, this is how I do these types of
things:

OnClientClick ='<%# String.format("return confirm('Are you certain you
want to delete: {0} ?'", Eval("UserName"))%>' />
Good luck!

mark4asp wrote:
How do I include a server tag within a javascript parameter which is
itself within a HTML element event.

For instance no matter what permutation of quotes I try here I get
errors on this line:

<asp:ImageButton ID="cmdDeleteLogin" runat="server"
SkinID="DeleteButton" CommandName="DeleteLogin"
CommandArgument='<%# Eval("LoginID") %>'
OnClientClick =
'return confirm(Are you certain you want to delete: <%#
Eval("UserName") %>)' />

I want the final code to look something like this:

<input type="image"
name="ctl00$ContentPlaceHolder$repLogins$ctl01$cmd EditLogin"
id="ctl00_ContentPlaceHolder_repLogins_ctl01_cmdEd itLogin"
src="../App_Themes/SomeSite_Admin/images/edit_button.gif"
onclick="return confirm('Are you certain you want to delete: Joe
Doe');"
style="border-width:0px;" />

Clearly the problem is that double quotes can't be used to enclose <%#
Eval("UserName") %but I need to enclose the argument to the
javascript confirm function in qutoes.

I found out what the problem was here
<http://blogs.clearscreen.com/ragc/archive/2004/10/28/525.aspxbut
there's no clue as to what the solution might be.
Nov 6 '06 #2
On 6 Nov 2006 11:33:43 -0800, "Superman" <br*****@ungernet.comwrote:
>Mark,

At first glance it looks like you're missing some single quotes (or
quotes around your confirm() call. The text is not wrapped!

If that doesn't yeild any results, this is how I do these types of
things:

OnClientClick ='<%# String.format("return confirm('Are you certain you
want to delete: {0} ?'", Eval("UserName"))%>' />
Thanks, I added a couple of bits which I thought should make it work
but they don't. I still ... I still get that error "server tag is not
well-formed". It's a mystery to me.

<asp:ImageButton ID="cmdDeleteLogin" runat="server"
SkinID="DeleteButton" CommandName="DeleteLogin"
CommandArgument='<%# Eval("LoginID") %>'
OnClientClick ='<%# System.String.Format("return confirm('Are you
certain you want to delete: {0} ?')", Eval("UserName")) %>' />
Nov 7 '06 #3

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

Similar topics

6
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object...
8
by: Brendan Reynolds | last post by:
I'm trying to integrate SQL Server Reporting Services reports into an ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL addressing, but this exposes in the query string...
5
by: Casey | last post by:
Hello, Can someone give me specific code to replace text on a page using server side javascript? I need to use server-side because I need the output to be recognized in the final HTML so that...
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"...
5
by: visu | last post by:
Hi this is a question asked in this group two years back.. No answer for this question till date. now i am in the same situation of the questioner.. to find a solution for this problem. Can any...
5
by: =?Utf-8?B?VmFubmk=?= | last post by:
Hi, I have a component where I need to have thread-safe access to a list. Operations on the list are done in critical sections (lock (lockObject) { ... } ) in the usual way, to make sure that no...
19
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.