PC Review


Reply
Thread Tools Rate Thread

How to develop

 
 
Peter
Guest
Posts: n/a
 
      30th Jul 2008
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


 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      30th Jul 2008
Hi,,

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

Best of luck

Munna
 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      30th Jul 2008
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:
(E-Mail Removed).
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter" <(E-Mail Removed)>
>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
>
>
>


 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      30th Jul 2008
Thank you!

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

"Steven Cheng [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:
> (E-Mail Removed).
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> --------------------
>>From: "Peter" <(E-Mail Removed)>
>>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
>>
>>
>>

>



 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      31st Jul 2008
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:
(E-Mail Removed).

==================================================
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" <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
>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]" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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
>>


 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      31st Jul 2008
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:
(E-Mail Removed).

==================================================
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" <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
>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]" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Develop CSP in XP SP3 izyani Windows XP 0 11th Dec 2008 06:46 AM
What OS do you develop on? Richard Carpenter Microsoft C# .NET 4 27th Apr 2008 05:23 PM
#develop jvax Microsoft C# .NET 3 15th Dec 2005 07:27 AM
Develop a Dot net Web App with something other than IIS? David Microsoft Dot NET Framework 2 4th Nov 2004 03:31 PM
Develop an add-on Yoni Stoffman Windows XP Messenger 0 27th Aug 2003 12:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:04 AM.