Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Saturday, March 31, 2012

Submitting the form correctly using the enter key

Hi all,

Simple problem:

I have a simple form and a submit and cancel image button underneath.

I also have a logout image button at the top of the page. This button is
rendered from a user control that is seperate from the form page itself.

At the moment if I press enter when inside a textbox the log out button is
activated. How can I make sure that the submit button is activated when the
user presses enter?

Many thanks all

Kind RegardsEnter activates the first submit button in the layout. See details at
http://www.allasp.net/enterkey.aspx

Can you place the logout button after the submit one?

Eliyahu

"thechaosengine" <sh856531@.microsofts_free_email_service.com> wrote in
message news:O5N%23amv9EHA.2996@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button is
> rendered from a user control that is seperate from the form page itself.
> At the moment if I press enter when inside a textbox the log out button is
> activated. How can I make sure that the submit button is activated when
the
> user presses enter?
> Many thanks all
> Kind Regards
thechaosengine wrote:
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button
> is rendered from a user control that is seperate from the form page
> itself.
> At the moment if I press enter when inside a textbox the log out
> button is activated. How can I make sure that the submit button is
> activated when the user presses enter?
> Many thanks all
> Kind Regards

You can capture the Enter key with JavaScript
to get the behavior you want:
http://dotnetjunkies.com/WebLog/dar...03/03/8374.aspx

--

Riki

Submitting the form correctly using the enter key

Hi all,
Simple problem:
I have a simple form and a submit and cancel image button underneath.
I also have a logout image button at the top of the page. This button is
rendered from a user control that is seperate from the form page itself.
At the moment if I press enter when inside a textbox the log out button is
activated. How can I make sure that the submit button is activated when the
user presses enter?
Many thanks all
Kind RegardsEnter activates the first submit button in the layout. See details at
http://www.allasp.net/enterkey.aspx
Can you place the logout button after the submit one?
Eliyahu
"thechaosengine" <sh856531@.microsofts_free_email_service.com> wrote in
message news:O5N%23amv9EHA.2996@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button is
> rendered from a user control that is seperate from the form page itself.
> At the moment if I press enter when inside a textbox the log out button is
> activated. How can I make sure that the submit button is activated when
the
> user presses enter?
> Many thanks all
> Kind Regards
>
thechaosengine wrote:
> Hi all,
> Simple problem:
> I have a simple form and a submit and cancel image button underneath.
> I also have a logout image button at the top of the page. This button
> is rendered from a user control that is seperate from the form page
> itself.
> At the moment if I press enter when inside a textbox the log out
> button is activated. How can I make sure that the submit button is
> activated when the user presses enter?
> Many thanks all
> Kind Regards
You can capture the Enter key with JavaScript
to get the behavior you want:
http://dotnetjunkies.com/WebLog/dar...03/03/8374.aspx
Riki

Subroutine /helper function error

I'm using a subroutine/helper function display an image (the image
would be displayed inside a datalist control's <itemtemplate> )
<script language="VB" runat="server">
Public Sub checkforimg(ByVal Imagesubprod1 As String)
If Imagesubprod1 <> "" then
response.write(Imagesubprod1)
Else
response.write("nbsp;")
End If
End Sub
</script>
... but I get an "Overload resolution failed because no accessible
'ToString' can be called with these arguments:" error when it comes
time to check for the image as follows.
<%# checkforimg(DataBinder.Eval(Container.DataItem,
"Imagesubprod1"))%>
When I form the header for the sub as follows:
Public Sub checkforimg(ByVal Imagesubprod1 As String) As string
..i get an "Expected end of statement " error on this lineOn 10 Jun 2004 11:55:42 -0700, Chumley the Walrus <springb2k@.yahoo.com>
wrote:

> I'm using a subroutine/helper function display an image (the image
> would be displayed inside a datalist control's <itemtemplate> )
> <script language="VB" runat="server">
> Public Sub checkforimg(ByVal Imagesubprod1 As String)
> If Imagesubprod1 <> "" then
> response.write(Imagesubprod1)
> Else
> response.write("nbsp;")
> End If
> End Sub
> </script>
> ... but I get an "Overload resolution failed because no accessible
> 'ToString' can be called with these arguments:" error when it comes
> time to check for the image as follows.
> <%# checkforimg(DataBinder.Eval(Container.DataItem,
> "Imagesubprod1"))%>
looks like it's having trouble converting the value you're passing in thru
databinding to a String. If you have Option Strict on, you might try
either casting the value in the databinding statement to a string before
passing it in, or change the parameter in your method above to an Object
and then cast it inside the function itself.
Otherwise verify the value in your datasource is truly capable of being a
string.
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
IE does not support inline images, so you code should be writing something
like: <img src=url> not the binary image.
-- bruce (sqlwork.com)
"Chumley the Walrus" <springb2k@.yahoo.com> wrote in message
news:1ef65641.0406101055.8852102@.posting.google.com...
> I'm using a subroutine/helper function display an image (the image
> would be displayed inside a datalist control's <itemtemplate> )
> <script language="VB" runat="server">
> Public Sub checkforimg(ByVal Imagesubprod1 As String)
> If Imagesubprod1 <> "" then
> response.write(Imagesubprod1)
> Else
> response.write("nbsp;")
> End If
> End Sub
> </script>
> ... but I get an "Overload resolution failed because no accessible
> 'ToString' can be called with these arguments:" error when it comes
> time to check for the image as follows.
> <%# checkforimg(DataBinder.Eval(Container.DataItem,
> "Imagesubprod1"))%>
> When I form the header for the sub as follows:
> Public Sub checkforimg(ByVal Imagesubprod1 As String) As string
> ..i get an "Expected end of statement " error on this line

Tuesday, March 13, 2012

Swapping Image Url

In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image
In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";

Here's the problem: on postback, the image control's .ImageUrl property
still contains "some.gif" and not "other.gif" as I am needing.

What do I need to do to receive - during postback - the value set in the
client by the JavaScript?

Thanks!After postback, the value of ImageUrl is coming from the control's ViewState.

One solution would be to set the value of a hidden field when you set the
image's src attribute. The value of the hidden field will get posted back
correctly.

"Guadala Harry" wrote:

> In an aspx page I have declared an Image control:
> <asp:Image id="myImage" runat="server"></asp:Image>
> In the code-behind I populate it's ImageURL property, like this:
> myImage.ImageUrl = "some.gif";
> Then, in client-side JavaScript, the user can cause the image to be
> replaced, like this:
> document.all("myImage").src = "other.gif";
> Here's the problem: on postback, the image control's .ImageUrl property
> still contains "some.gif" and not "other.gif" as I am needing.
> What do I need to do to receive - during postback - the value set in the
> client by the JavaScript?
> Thanks!
>
>
Thanks - I thought about going the hidden field route - but was hoping for
some solution that wouldn't require adding another field or control that
needs synchronizing with the original Image control.

Any other ideas?

Thanks again...

-G

"Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> After postback, the value of ImageUrl is coming from the control's
ViewState.
> One solution would be to set the value of a hidden field when you set the
> image's src attribute. The value of the hidden field will get posted back
> correctly.
> "Guadala Harry" wrote:
> > In an aspx page I have declared an Image control:
> > <asp:Image id="myImage" runat="server"></asp:Image>
> > In the code-behind I populate it's ImageURL property, like this:
> > myImage.ImageUrl = "some.gif";
> > Then, in client-side JavaScript, the user can cause the image to be
> > replaced, like this:
> > document.all("myImage").src = "other.gif";
> > Here's the problem: on postback, the image control's .ImageUrl property
> > still contains "some.gif" and not "other.gif" as I am needing.
> > What do I need to do to receive - during postback - the value set in the
> > client by the JavaScript?
> > Thanks!
Can you make the code in your codebehind only execute the first time it
executes? i.e.

if (!Page.IsPostback)
myImage.ImageUrl = "some.gif";

Toby Mathews

"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> Thanks - I thought about going the hidden field route - but was hoping for
> some solution that wouldn't require adding another field or control that
> needs synchronizing with the original Image control.
> Any other ideas?
> Thanks again...
> -G
>
> "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> > After postback, the value of ImageUrl is coming from the control's
> ViewState.
> > One solution would be to set the value of a hidden field when you set
the
> > image's src attribute. The value of the hidden field will get posted
back
> > correctly.
> > "Guadala Harry" wrote:
> > > In an aspx page I have declared an Image control:
> > > <asp:Image id="myImage" runat="server"></asp:Image>
> > > > In the code-behind I populate it's ImageURL property, like this:
> > > myImage.ImageUrl = "some.gif";
> > > > Then, in client-side JavaScript, the user can cause the image to be
> > > replaced, like this:
> > > document.all("myImage").src = "other.gif";
> > > > Here's the problem: on postback, the image control's .ImageUrl
property
> > > still contains "some.gif" and not "other.gif" as I am needing.
> > > > What do I need to do to receive - during postback - the value set in
the
> > > client by the JavaScript?
> > > > Thanks!
> > > >
That's not really relevant to the problem - it would be IF there was an
issue with postback processing walking on the value set in the client - but
issue is that the value set in the client code is never making it to the
server (unless I explicitly stuff the value into a hidden field - which I
don't want to do unless I really must).

Thanks anyway.

"Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
news:cfhs1q$87n$1@.thorium.cix.co.uk...
> Can you make the code in your codebehind only execute the first time it
> executes? i.e.
> if (!Page.IsPostback)
> myImage.ImageUrl = "some.gif";
> Toby Mathews
> "Guadala Harry" <GMan@.NoSpam.com> wrote in message
> news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> > Thanks - I thought about going the hidden field route - but was hoping
for
> > some solution that wouldn't require adding another field or control that
> > needs synchronizing with the original Image control.
> > Any other ideas?
> > Thanks again...
> > -G
> > "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> > news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> > > After postback, the value of ImageUrl is coming from the control's
> > ViewState.
> > > > One solution would be to set the value of a hidden field when you set
> the
> > > image's src attribute. The value of the hidden field will get posted
> back
> > > correctly.
> > > > "Guadala Harry" wrote:
> > > > > In an aspx page I have declared an Image control:
> > > > <asp:Image id="myImage" runat="server"></asp:Image>
> > > > > > In the code-behind I populate it's ImageURL property, like this:
> > > > myImage.ImageUrl = "some.gif";
> > > > > > Then, in client-side JavaScript, the user can cause the image to be
> > > > replaced, like this:
> > > > document.all("myImage").src = "other.gif";
> > > > > > Here's the problem: on postback, the image control's .ImageUrl
> property
> > > > still contains "some.gif" and not "other.gif" as I am needing.
> > > > > > What do I need to do to receive - during postback - the value set in
> the
> > > > client by the JavaScript?
> > > > > > Thanks!
> > > > > > > >
Harry,

Sorry, I didn't read your message properly first time round. I'm not sure
how else you could achieve what you want to do other than how you decribe.
Good luck,

Toby

"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23Tkt9DRgEHA.1048@.tk2msftngp13.phx.gbl...
> That's not really relevant to the problem - it would be IF there was an
> issue with postback processing walking on the value set in the client -
but
> issue is that the value set in the client code is never making it to the
> server (unless I explicitly stuff the value into a hidden field - which I
> don't want to do unless I really must).
> Thanks anyway.
>
> "Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
> news:cfhs1q$87n$1@.thorium.cix.co.uk...
> > Can you make the code in your codebehind only execute the first time it
> > executes? i.e.
> > if (!Page.IsPostback)
> > myImage.ImageUrl = "some.gif";
> > Toby Mathews
> > "Guadala Harry" <GMan@.NoSpam.com> wrote in message
> > news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> > > Thanks - I thought about going the hidden field route - but was hoping
> for
> > > some solution that wouldn't require adding another field or control
that
> > > needs synchronizing with the original Image control.
> > > > Any other ideas?
> > > > Thanks again...
> > > > -G
> > > > > > "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> > > news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> > > > After postback, the value of ImageUrl is coming from the control's
> > > ViewState.
> > > > > > One solution would be to set the value of a hidden field when you
set
> > the
> > > > image's src attribute. The value of the hidden field will get
posted
> > back
> > > > correctly.
> > > > > > "Guadala Harry" wrote:
> > > > > > > In an aspx page I have declared an Image control:
> > > > > <asp:Image id="myImage" runat="server"></asp:Image>
> > > > > > > > In the code-behind I populate it's ImageURL property, like this:
> > > > > myImage.ImageUrl = "some.gif";
> > > > > > > > Then, in client-side JavaScript, the user can cause the image to
be
> > > > > replaced, like this:
> > > > > document.all("myImage").src = "other.gif";
> > > > > > > > Here's the problem: on postback, the image control's .ImageUrl
> > property
> > > > > still contains "some.gif" and not "other.gif" as I am needing.
> > > > > > > > What do I need to do to receive - during postback - the value set
in
> > the
> > > > > client by the JavaScript?
> > > > > > > > Thanks!
> > > > > > > > > > > > > >

Swapping Image Url

In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image>
In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";
Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";
Here's the problem: on postback, the image control's .ImageUrl property
still contains "some.gif" and not "other.gif" as I am needing.
What do I need to do to receive - during postback - the value set in the
client by the JavaScript?
Thanks!After postback, the value of ImageUrl is coming from the control's ViewState
.
One solution would be to set the value of a hidden field when you set the
image's src attribute. The value of the hidden field will get posted back
correctly.
"Guadala Harry" wrote:

> In an aspx page I have declared an Image control:
> <asp:Image id="myImage" runat="server"></asp:Image>
> In the code-behind I populate it's ImageURL property, like this:
> myImage.ImageUrl = "some.gif";
> Then, in client-side JavaScript, the user can cause the image to be
> replaced, like this:
> document.all("myImage").src = "other.gif";
> Here's the problem: on postback, the image control's .ImageUrl property
> still contains "some.gif" and not "other.gif" as I am needing.
> What do I need to do to receive - during postback - the value set in the
> client by the JavaScript?
> Thanks!
>
>
Thanks - I thought about going the hidden field route - but was hoping for
some solution that wouldn't require adding another field or control that
needs synchronizing with the original Image control.
Any other ideas?
Thanks again...
-G
"Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> After postback, the value of ImageUrl is coming from the control's
ViewState.
> One solution would be to set the value of a hidden field when you set the
> image's src attribute. The value of the hidden field will get posted back
> correctly.
> "Guadala Harry" wrote:
>
Can you make the code in your codebehind only execute the first time it
executes? i.e.
if (!Page.IsPostback)
myImage.ImageUrl = "some.gif";
Toby Mathews
"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> Thanks - I thought about going the hidden field route - but was hoping for
> some solution that wouldn't require adding another field or control that
> needs synchronizing with the original Image control.
> Any other ideas?
> Thanks again...
> -G
>
> "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> ViewState.
the
back
property
the
>
That's not really relevant to the problem - it would be IF there was an
issue with postback processing walking on the value set in the client - but
issue is that the value set in the client code is never making it to the
server (unless I explicitly stuff the value into a hidden field - which I
don't want to do unless I really must).
Thanks anyway.
"Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
news:cfhs1q$87n$1@.thorium.cix.co.uk...
> Can you make the code in your codebehind only execute the first time it
> executes? i.e.
> if (!Page.IsPostback)
> myImage.ImageUrl = "some.gif";
> Toby Mathews
> "Guadala Harry" <GMan@.NoSpam.com> wrote in message
> news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
for
> the
> back
> property
> the
>
Harry,
Sorry, I didn't read your message properly first time round. I'm not sure
how else you could achieve what you want to do other than how you decribe.
Good luck,
Toby
"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23Tkt9DRgEHA.1048@.tk2msftngp13.phx.gbl...
> That's not really relevant to the problem - it would be IF there was an
> issue with postback processing walking on the value set in the client -
but
> issue is that the value set in the client code is never making it to the
> server (unless I explicitly stuff the value into a hidden field - which I
> don't want to do unless I really must).
> Thanks anyway.
>
> "Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
> news:cfhs1q$87n$1@.thorium.cix.co.uk...
> for
that
set
posted
be
in
>

Switch Image

How do i switch an image after a user select/browse another image. I'm able to save the image back in the server database. but is not able to switch to the selected image. Please help...Could you please give us more information on what you are trying to do, and perhaps some code?

Ok, a user in the system which profile has been stored in the database including the path of his photo is viewing his particular. ie: name, address, phone number, his picture, etc. This user wish to change his current photo posted before. Thus, a HTML FileField is provided for him to browse the image and save it into our server. What i want to do is, when a user click on the Update button. The older picture shown in the page will be replaced with his newly given picture. The path of the picture stored in server is successfully updated. And I set the code to retrieve this user's profile including his picture from the database again after the Update button is clicked. I've tested the code by Updating picture and certain information, i noticed that all information can be updated and replacing the old information on the screen except that the picture did not change to the newly added picture in the database. Any idea...?
Try to add this to your page:
<meta http-equiv="Expires" content="0" />

Thanks PaaB. But it's not working. Where do i put that line anyway. I put it in between <HEAD> and </HEAD>. Am i right?

Yes it is the right place.
Can you show the source code.
When user chnege the image, is then changed path and name of the picture? I think about that when would be changed only path and not name of the picture then IE possibly use picture saved on client computer?


As i mentioned earlier. I have a HTML FileField where user can browse image and update it. the system will then saved the image into the server and update the directory stored in database. Finally, the system should display the latest image newly added by this user, but it is not. The path and directory of new image is updated in the database. same goes to the image saved in the server. I don't know if i'm right. if wrong, please correct me. i think that the system take the same image downloaded previously in temp folder. and if i'm right, is there any method that i can call client computer to download the image again? Please advise...Thank u


What object do you use for display picture - Image Web Control or Image Html Element? Do you update the ImageUrl/src parameter on the "uploading" postback?


I'm using Html element. After the new image has been saved on the server and its directory in the database. User can choose to view the same info again by a single click. Thus, i recall the sub that display the information once again. the code for image is like this.

myCommand =New SqlCommand("SELECT * FROM User_Profile WHERE ([User_ID] = '" & userid & "' AND [Company_ID] = '" & compid & "')", myConnection)

myReader = myCommand.ExecuteReader

myReader.Read()

imgUser.Src = myReader.Item("Photo")

thats it.. any mistake on this one?


This isn't related to your image issue, but you should be using Parameters with your SQL statement:

myCommand =NewSqlCommand("SELECT * FROM User_Profile WHERE ([User_ID] = @.user_id AND [Company_ID] = @.company_id ')",myConnection)
myCommand.Parameters.Add(New SqlParameter("@.user_id",SqlDbType.Integer)).Value = userid
myCommand.Parameters.Add(New SqlParameter("@.company_id",SqlDbType.Integer)).Value = compid




tried your suggestion, but it's not working. And even other information also is not displaying. i know the usage of parameters, usually i used it with stored procedure. there's nothing wrong with plain sql command compare with 1 that using parameter right?

nickless1 wrote:


imgUser.Src = myReader.Item("Photo")


You might try this to see if it makes a difference:
imgUser.Src = myReader.Item("Photo") & "?" & System.DateTime.Now().ToString()
Also, see this KB article:IIS: How to Disable Caching of Specific MIME Types

nickless1 wrote:


tried your suggestion, but it's not working. And even other informationalso is not displaying. i know the usage of parameters, usually i usedit with stored procedure. there's nothing wrong with plain sql commandcompare with 1 that using parameter right?


Sorry, I shouldn't have confused the issue. To protect yourself fromSQL injectionyou should always use parameters in SQL statements; you should neverconcatenate user-supplied data to a string to be executed. Ididn't meant to introduce another problem, however. Once you havesolved your image caching problem you can post another question aboutthe parameter problem.

Yes...It works. Thanks a lot. I couldn't open the page u gave. Would u mind to explain how it works? Thanks again...
I'm glad that approach worked for you. (And I've now corrected the link that I posted.)

Hi,
Im having kind of the same problem you have. Could you explain how you managed to solve it? as you might now, this issue is a brainbuster! :S