472,980 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to solve this " problem? Thank You.

Hello,

I have an ASP:ImageButton where I want to call a function and pass a
string:

OnClick="Change_Photo("John")"

I am having problems with "".

I tried
OnClick="Change_Photo('John')"

And

OnClick="Change_Photo(''John'')"

I wasn't able to make this work.

What do I need to fix this?

Thanks,
Miguel

Nov 19 '05 #1
7 1968
Well, I'm not sure about the language for which this string will be used, so
the solution is either to use two " for each embedded " or to use a backlash
\:

OnClick="Change_Photo(""John"")"

or :
OnClick="Change_Photo(\"John\")"

However, the fact that the end result might be displayed inside an HTML page
and be used as part of a Javascript or a VBScript instruction might make
things a little more complicated; so none of the above might be your
solution.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
Hello,

I have an ASP:ImageButton where I want to call a function and pass a
string:

OnClick="Change_Photo("John")"

I am having problems with "".

I tried
OnClick="Change_Photo('John')"

And

OnClick="Change_Photo(''John'')"

I wasn't able to make this work.

What do I need to fix this?

Thanks,
Miguel

Nov 19 '05 #2
Hi,

None of that worked.

Does anyone else know how to solve this?

Thanks,
Miguel

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:sylvain aei ca (fill the blanks, no spam please):
Well, I'm not sure about the language for which this string will be used, so
the solution is either to use two " for each embedded " or to use a backlash
\:

OnClick="Change_Photo(""John"")"

or :
OnClick="Change_Photo(\"John\")"

However, the fact that the end result might be displayed inside an HTML page
and be used as part of a Javascript or a VBScript instruction might make
things a little more complicated; so none of the above might be your
solution.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
Hello,

I have an ASP:ImageButton where I want to call a function and pass a
string:

OnClick="Change_Photo("John")"

I am having problems with "".

I tried
OnClick="Change_Photo('John')"

And

OnClick="Change_Photo(''John'')"

I wasn't able to make this work.

What do I need to fix this?

Thanks,
Miguel


Nov 19 '05 #3
I'm not sure if you're trying to run client script or have a method called
on postback.

For client script you'll need to use the following:

imgButton.Attributes.Add("onclick", "Change_Photo('John')");

If you need to handle a postback the you need to add an event handler to
your code. If you need to pass a string back, then you'll want to use the
Command event and set the CommandArgument to the value you want to be
returned during the postback.

imgButton.Command += new CommandEventHandler(img_Command);

in the event handler you can get teh value from the
CommandEventArgs.CommandArgument property.
IHTH

Jon

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

None of that worked.

Does anyone else know how to solve this?

Thanks,
Miguel

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:sylvain aei ca (fill the blanks, no spam please):
Well, I'm not sure about the language for which this string will be used,
so
the solution is either to use two " for each embedded " or to use a
backlash
\:

OnClick="Change_Photo(""John"")"

or :
OnClick="Change_Photo(\"John\")"

However, the fact that the end result might be displayed inside an HTML
page
and be used as part of a Javascript or a VBScript instruction might make
things a little more complicated; so none of the above might be your
solution.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have an ASP:ImageButton where I want to call a function and pass a
> string:
>
> OnClick="Change_Photo("John")"
>
> I am having problems with "".
>
> I tried
> OnClick="Change_Photo('John')"
>
> And
>
> OnClick="Change_Photo(''John'')"
>
> I wasn't able to make this work.
>
> What do I need to fix this?
>
> Thanks,
> Miguel
>

Nov 19 '05 #4
Hi,

It's not that. In my HTML code I have an image button:
<asp:ImageButton id="ib" runat="server" CssClass="ib"
OnClick="Change_Photo("image01_url")" Width="56"></asp:ImageButton>

The double quotes are the problem.

In my aspx.vb code I have the function:
Public Sub Change_Photo
....
End Sub

I know I could add the OnClick event in my aspx.vb but I would like to
solve this problem in my HTML code. I would prefer to have it there.

Thanks,
Miguel

"CodeMeister" <jw********@codemeister.net> wrote in message
news:jw********@codemeister.net:
I'm not sure if you're trying to run client script or have a method called
on postback.

For client script you'll need to use the following:

imgButton.Attributes.Add("onclick", "Change_Photo('John')");

If you need to handle a postback the you need to add an event handler to
your code. If you need to pass a string back, then you'll want to use the
Command event and set the CommandArgument to the value you want to be
returned during the postback.

imgButton.Command += new CommandEventHandler(img_Command);

in the event handler you can get teh value from the
CommandEventArgs.CommandArgument property.
IHTH

Jon

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

None of that worked.

Does anyone else know how to solve this?

Thanks,
Miguel

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:sylvain aei ca (fill the blanks, no spam please):

Well, I'm not sure about the language for which this string will be used,
so
the solution is either to use two " for each embedded " or to use a
backlash
\:

OnClick="Change_Photo(""John"")"

or :
OnClick="Change_Photo(\"John\")"

However, the fact that the end result might be displayed inside an HTML
page
and be used as part of a Javascript or a VBScript instruction might make
things a little more complicated; so none of the above might be your
solution.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
Hello,
>
> I have an ASP:ImageButton where I want to call a function and pass a
> string:
>
> OnClick="Change_Photo("John")"
>
> I am having problems with "".
>
> I tried
> OnClick="Change_Photo('John')"
>
> And
>
> OnClick="Change_Photo(''John'')"
>
> I wasn't able to make this work.
>
> What do I need to fix this?
>
> Thanks,
> Miguel
>



Nov 19 '05 #5
Miguel,

(1) use ib.Attributes.Add("onclick", "Change_Photo('image01_url')") in the
page.load event in your aspx.vb file to register the client side function.

(2) write a client side function which will change the picture.

Greetings

Daniel
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> schrieb im Newsbeitrag
news:uN*************@TK2MSFTNGP12.phx.gbl...
Hi,

It's not that. In my HTML code I have an image button:
<asp:ImageButton id="ib" runat="server" CssClass="ib"
OnClick="Change_Photo("image01_url")" Width="56"></asp:ImageButton>

The double quotes are the problem.

In my aspx.vb code I have the function:
Public Sub Change_Photo
...
End Sub

I know I could add the OnClick event in my aspx.vb but I would like to
solve this problem in my HTML code. I would prefer to have it there.

Thanks,
Miguel

"CodeMeister" <jw********@codemeister.net> wrote in message
news:jw********@codemeister.net:
I'm not sure if you're trying to run client script or have a method
called
on postback.

For client script you'll need to use the following:

imgButton.Attributes.Add("onclick", "Change_Photo('John')");

If you need to handle a postback the you need to add an event handler to
your code. If you need to pass a string back, then you'll want to use the
Command event and set the CommandArgument to the value you want to be
returned during the postback.

imgButton.Command += new CommandEventHandler(img_Command);

in the event handler you can get teh value from the
CommandEventArgs.CommandArgument property.
IHTH

Jon

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> None of that worked.
>
> Does anyone else know how to solve this?
>
> Thanks,
> Miguel
>
> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
> wrote in message news:sylvain aei ca (fill the blanks, no spam please):
>

>> Well, I'm not sure about the language for which this string will be
>> used,
>> so
>> the solution is either to use two " for each embedded " or to use a
>> backlash
>> \:
>>
>> OnClick="Change_Photo(""John"")"
>>
>> or :
>> OnClick="Change_Photo(\"John\")"
>>
>> However, the fact that the end result might be displayed inside an
>> HTML
>> page
>> and be used as part of a Javascript or a VBScript instruction might
>> make
>> things a little more complicated; so none of the above might be your
>> solution.
>>
>>
>> --
>> Sylvain Lafontaine, ing.
>> MVP - Technologies Virtual-PC
>> E-mail: http://cerbermail.com/?QugbLEWINF
>>
>>
>> "Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
>> news:O5**************@TK2MSFTNGP09.phx.gbl...
>>

>> > Hello,
>> >
>> > I have an ASP:ImageButton where I want to call a function and pass a
>> > string:
>> >
>> > OnClick="Change_Photo("John")"
>> >
>> > I am having problems with "".
>> >
>> > I tried
>> > OnClick="Change_Photo('John')"
>> >
>> > And
>> >
>> > OnClick="Change_Photo(''John'')"
>> >
>> > I wasn't able to make this work.
>> >
>> > What do I need to fix this?
>> >
>> > Thanks,
>> > Miguel
>> >

>

Nov 19 '05 #6
Shapper wrote:
Hi,

It's not that. In my HTML code I have an image button:
<asp:ImageButton id="ib" runat="server" CssClass="ib"
OnClick="Change_Photo("image01_url")" Width="56"></asp:ImageButton>

The double quotes are the problem.

In my aspx.vb code I have the function:
Public Sub Change_Photo
...
End Sub

I know I could add the OnClick event in my aspx.vb but I would like to
solve this problem in my HTML code. I would prefer to have it there.

Thanks,
Miguel


The problem is that the 'event' attributes on the HTML markup of server
controls, the ones that map to an actual event on the class for that
control, define what handler method the server code will call for the
event. All you can put in there is a method name, not an actual call
with an arg, etc.

What CodeMeister was getting at was that to pass more info along to the
handler, you can use the OnCommand event/attribute instead (as well as a
couple other attributes). These can be defined in the code-front, where
you map it to a handler method you define that then looks inside the
eventArg info to see what exactly happened.

More info/examples:

http://authors.aspalliance.com/aspxt...ebcontrol.aspx

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #7
Shapper wrote:
Hi,

It's not that. In my HTML code I have an image button:
<asp:ImageButton id="ib" runat="server" CssClass="ib"
OnClick="Change_Photo("image01_url")" Width="56"></asp:ImageButton>

The double quotes are the problem.

In my aspx.vb code I have the function:
Public Sub Change_Photo
...
End Sub


OK, so your OnClick is a *server side* function, that was not clear
from your other posts.

Would this work:
OnClick='Change_Photo("image01_url")'

(so: keep the double quotes around "image01_url" and use single quotes
around the whole OnClick value)

Hans Kesting
Nov 19 '05 #8

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

Similar topics

10
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following...
1
by: Shapper | last post by:
Hello, I am accessing a value in a XML value: news.Load(Server.MapPath("xml/ news.rss")) newslabel.Text = CType(news.SelectSingleNode("rss version=&quot;2.0 &quot;/channel/title").InnerText, String) ...
6
by: Federico | last post by:
Hi, this is what I can do: - Create new solutions using VS.Net ASP.Net - Save the solutions, build the solution, view in browser with the solution still open. But, once I close the solution, I...
5
by: han zhiyang | last post by:
Hi. I tried to design a custom web control which can flexibly and dynamicly let the control user ,for example the web page developer, customize its layout codes.This control derives from...
0
by: mrajsenkumar | last post by:
Hi I am using windowsCE 5.0, here i am try to deploy the project. but i got error message - "Connection failed. Device is not ready." tell me how to solve this problem.very urgent. i am using vs2005.
1
by: rocksoft | last post by:
Hi, i got error "class not registered" when i try to create web setup and deployment project to my web application. i'm used Asp.net and c# to my application, i created web setup and deployment...
0
by: 2Barter.net | last post by:
Date: Feb 24, 2007 12:12 PM Subject: Re: " Skit Kittie Cat Skit " On "CLICK" to see laughing, chuckling, chortling, guffawing, giggling, tittering, twittering, cackling, sniggering; informal...
4
by: namalapavan | last post by:
hii , i am getting and error while installing oracle9i on RHEL AS 4.0 .i am sure that somebody here would be able to solve my problem.kindly reply so that i can send you the detailed error report....
13
by: Anna | last post by:
I try to put 8 int bit for example 10100010 into one character of type char(1 octet) with no hope . Could anyone propose a simple way to do it? Thank you very much.
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.