Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   How to develop (http://www.velocityreviews.com/forums/t628249-how-to-develop.html)

Peter 07-30-2008 05:55 AM

How to develop
 
I have a general question of how to do this?

I have a webpage with 5 buttons and a 1 text box. The idea is if I click on
any of the buttons a text should appear in the text box related to the
button.
My question is what is the best way to program this?

I tried to use AJAX and update panel, but it's too slow, when I click on the
button it takes 1 or 2 seconds to display the text, long enough for user to
wonder what's going on and click on the button again or click on something
else.

Should I use hidden field for each button (with JavaScript) and move the
text from the hidden field in to the Text box when user clicks on a button?
Should I use 5 hidden text boxes and show / hide them when user clicks on a
button?

Which one is the most efficient?

Should I use ASP.NET buttons or HTML buttons or something else?

Or is there a better way to do this?

Thank You


Peter



Munna 07-30-2008 07:23 AM

Re: How to develop
 
Hi,,

if you want to no delay... javascript is good since all happens in
client side...

Best of luck

Munna

Steven Cheng [MSFT] 07-30-2008 08:47 AM

RE: How to develop
 
Hi Peter,

I agree with Munna that using pure client-side script to do the message
displaying task is preferred(if the messages can be statically determined
after page render ) and postback or AJAX is unnecessary. here is very
simple page to demonstrate the javascript approach:

# I used a statically defined javascript array, for your scenario, you can
also use Page.ClientScript.RegisterXXX method to emit such a client script
variable in codebehind(such as from some database records...):
===============================
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">

var messages = new
Array("message1","message2","message3","message4", "message5");

function display_message(index)
{
alert(messages[index]);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button1"
OnClientClick="display_message(0);" />
<asp:Button ID="Button2" runat="server" Text="Button2"
OnClientClick="display_message(1);" />
<asp:Button ID="Button3" runat="server" Text="Button3"
OnClientClick="display_message(2);" />
<asp:Button ID="Button4" runat="server" Text="Button4"
OnClientClick="display_message(3);" />
<asp:Button ID="Button5" runat="server" Text="Button5"
OnClientClick="display_message(4);" />

</div>
</form>
</body>
</html>

================================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter" <czupet@nospam.nospam>
>Subject: How to develop
>Date: Wed, 30 Jul 2008 00:55:16 -0500


>
>I have a general question of how to do this?
>
>I have a webpage with 5 buttons and a 1 text box. The idea is if I click

on
>any of the buttons a text should appear in the text box related to the
>button.
>My question is what is the best way to program this?
>
>I tried to use AJAX and update panel, but it's too slow, when I click on

the
>button it takes 1 or 2 seconds to display the text, long enough for user

to
>wonder what's going on and click on the button again or click on something
>else.
>
>Should I use hidden field for each button (with JavaScript) and move the
>text from the hidden field in to the Text box when user clicks on a button?
>Should I use 5 hidden text boxes and show / hide them when user clicks on

a
>button?
>
>Which one is the most efficient?
>
>Should I use ASP.NET buttons or HTML buttons or something else?
>
>Or is there a better way to do this?
>
>Thank You
>
>
>Peter
>
>
>



Peter 07-30-2008 12:57 PM

Re: How to develop
 
Thank you!

This is a good idea, just what I was looking for!

"Steven Cheng [MSFT]" <stcheng@online.microsoft.com> wrote in message
news:Vetr7Ji8IHA.4744@TK2MSFTNGHUB02.phx.gbl...
> Hi Peter,
>
> I agree with Munna that using pure client-side script to do the message
> displaying task is preferred(if the messages can be statically determined
> after page render ) and postback or AJAX is unnecessary. here is very
> simple page to demonstrate the javascript approach:
>
> # I used a statically defined javascript array, for your scenario, you can
> also use Page.ClientScript.RegisterXXX method to emit such a client script
> variable in codebehind(such as from some database records...):
> ===============================
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head runat="server">
> <title>Untitled Page</title>
> <script type="text/javascript">
>
> var messages = new
> Array("message1","message2","message3","message4", "message5");
>
> function display_message(index)
> {
> alert(messages[index]);
> }
> </script>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
>
> <asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>
> <br />
> <asp:Button ID="Button1" runat="server" Text="Button1"
> OnClientClick="display_message(0);" />
> <asp:Button ID="Button2" runat="server" Text="Button2"
> OnClientClick="display_message(1);" />
> <asp:Button ID="Button3" runat="server" Text="Button3"
> OnClientClick="display_message(2);" />
> <asp:Button ID="Button4" runat="server" Text="Button4"
> OnClientClick="display_message(3);" />
> <asp:Button ID="Button5" runat="server" Text="Button5"
> OnClientClick="display_message(4);" />
>
> </div>
> </form>
> </body>
> </html>
>
> ================================
>
> Hope this helps.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> msdnmg@microsoft.com.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> --------------------
>>From: "Peter" <czupet@nospam.nospam>
>>Subject: How to develop
>>Date: Wed, 30 Jul 2008 00:55:16 -0500

>
>>
>>I have a general question of how to do this?
>>
>>I have a webpage with 5 buttons and a 1 text box. The idea is if I click

> on
>>any of the buttons a text should appear in the text box related to the
>>button.
>>My question is what is the best way to program this?
>>
>>I tried to use AJAX and update panel, but it's too slow, when I click on

> the
>>button it takes 1 or 2 seconds to display the text, long enough for user

> to
>>wonder what's going on and click on the button again or click on something
>>else.
>>
>>Should I use hidden field for each button (with JavaScript) and move the
>>text from the hidden field in to the Text box when user clicks on a
>>button?
>>Should I use 5 hidden text boxes and show / hide them when user clicks on

> a
>>button?
>>
>>Which one is the most efficient?
>>
>>Should I use ASP.NET buttons or HTML buttons or something else?
>>
>>Or is there a better way to do this?
>>
>>Thank You
>>
>>
>>Peter
>>
>>
>>

>




Steven Cheng [MSFT] 07-31-2008 01:56 AM

Re: How to develop
 
You're welcome Peter.

Have a good day!

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter" <czupet@nospam.nospam>
>References: <uNUfYjg8IHA.3768@TK2MSFTNGP04.phx.gbl>

<Vetr7Ji8IHA.4744@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: How to develop
>Date: Wed, 30 Jul 2008 07:57:51 -0500


>
>Thank you!
>
>This is a good idea, just what I was looking for!
>
>"Steven Cheng [MSFT]" <stcheng@online.microsoft.com> wrote in message
>news:Vetr7Ji8IHA.4744@TK2MSFTNGHUB02.phx.gbl...
>> Hi Peter,
>>
>> I agree with Munna that using pure client-side script to do the message
>> displaying task is preferred(if the messages can be statically determined
>> after page render ) and postback or AJAX is unnecessary. here is very
>> simple page to demonstrate the javascript approach:
>>
>> # I used a statically defined javascript array, for your scenario, you

can
>> also use Page.ClientScript.RegisterXXX method to emit such a client

script
>> variable in codebehind(such as from some database records...):
>> ===============================
>> <html xmlns="http://www.w3.org/1999/xhtml">
>> <head runat="server">
>> <title>Untitled Page</title>
>> <script type="text/javascript">
>>
>> var messages = new
>> Array("message1","message2","message3","message4", "message5");
>>
>> function display_message(index)
>> {
>> alert(messages[index]);
>> }
>> </script>
>> </head>
>> <body>
>> <form id="form1" runat="server">
>> <div>
>>
>> <asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>
>> <br />
>> <asp:Button ID="Button1" runat="server" Text="Button1"
>> OnClientClick="display_message(0);" />
>> <asp:Button ID="Button2" runat="server" Text="Button2"
>> OnClientClick="display_message(1);" />
>> <asp:Button ID="Button3" runat="server" Text="Button3"
>> OnClientClick="display_message(2);" />
>> <asp:Button ID="Button4" runat="server" Text="Button4"
>> OnClientClick="display_message(3);" />
>> <asp:Button ID="Button5" runat="server" Text="Button5"
>> OnClientClick="display_message(4);" />
>>
>> </div>
>> </form>
>> </body>
>> </html>
>>
>> ================================
>>
>> Hope this helps.
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>



Steven Cheng [MSFT] 07-31-2008 01:56 AM

Re: How to develop
 
You're welcome Peter.

Have a good day!

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter" <czupet@nospam.nospam>
>References: <uNUfYjg8IHA.3768@TK2MSFTNGP04.phx.gbl>

<Vetr7Ji8IHA.4744@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: How to develop
>Date: Wed, 30 Jul 2008 07:57:51 -0500


>
>Thank you!
>
>This is a good idea, just what I was looking for!
>
>"Steven Cheng [MSFT]" <stcheng@online.microsoft.com> wrote in message
>news:Vetr7Ji8IHA.4744@TK2MSFTNGHUB02.phx.gbl...
>> Hi Peter,
>>
>> I agree with Munna that using pure client-side script to do the message
>> displaying task is preferred(if the messages can be statically determined
>> after page render ) and postback or AJAX is unnecessary. here is very
>> simple page to demonstrate the javascript approach:
>>
>> # I used a statically defined javascript array, for your scenario, you

can
>> also use Page.ClientScript.RegisterXXX method to emit such a client

script
>> variable in codebehind(such as from some database records...):
>> ===============================
>> <html xmlns="http://www.w3.org/1999/xhtml">
>> <head runat="server">
>> <title>Untitled Page</title>
>> <script type="text/javascript">
>>
>> var messages = new
>> Array("message1","message2","message3","message4", "message5");
>>
>> function display_message(index)
>> {
>> alert(messages[index]);
>> }
>> </script>
>> </head>
>> <body>
>> <form id="form1" runat="server">
>> <div>
>>
>> <asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>
>> <br />
>> <asp:Button ID="Button1" runat="server" Text="Button1"
>> OnClientClick="display_message(0);" />
>> <asp:Button ID="Button2" runat="server" Text="Button2"
>> OnClientClick="display_message(1);" />
>> <asp:Button ID="Button3" runat="server" Text="Button3"
>> OnClientClick="display_message(2);" />
>> <asp:Button ID="Button4" runat="server" Text="Button4"
>> OnClientClick="display_message(3);" />
>> <asp:Button ID="Button5" runat="server" Text="Button5"
>> OnClientClick="display_message(4);" />
>>
>> </div>
>> </form>
>> </body>
>> </html>
>>
>> ================================
>>
>> Hope this helps.
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>




All times are GMT. The time now is 11:05 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57