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

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
Jul 30 '08 #1
5 1158
Hi,,

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

Best of luck

Munna
Jul 30 '08 #2
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:
ms****@microsoft.com.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter" <cz****@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
Jul 30 '08 #3
Thank you!

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

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:Ve**************@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:
ms****@microsoft.com.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>From: "Peter" <cz****@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

Jul 30 '08 #4
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:
ms****@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" <cz****@nospam.nospam>
References: <uN**************@TK2MSFTNGP04.phx.gbl>
<Ve**************@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]" <st*****@online.microsoft.comwrote in message
news:Ve**************@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
Jul 31 '08 #5
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:
ms****@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" <cz****@nospam.nospam>
References: <uN**************@TK2MSFTNGP04.phx.gbl>
<Ve**************@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]" <st*****@online.microsoft.comwrote in message
news:Ve**************@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
Jul 31 '08 #6

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

Similar topics

4
by: Jonathan Li | last post by:
I have posted the question before but nobody have given me a solution. I would like to rephrase my requirement and want to hear your advice. We are developing application packages for logistics...
2
by: [b2:ss] | last post by:
Can i distribute an application made with #develop under some commercial license (sahreware)? The GNU license is valid for modifyed versions of #develop source code only, or also for software made...
13
by: charliewest | last post by:
I am somewhat confused with what tool i need to develop Web applications w/ ASP.NET 2.0. Is it possible to use VS .Net 2003, or do i need to use the Beta versions of 2005 - Visual Web Developer...
1
by: Patrick | last post by:
With VS.NET Standard (not VS.NET Professional). Can i develop windows Services with this? Also, can i develop components for .NET Remoting? Currently I develop windows services with my VS.NET...
2
by: John A. Bailo | last post by:
I've been following these guys for a while and use their GPL'd ICSharpZip library quite a bit. The #develop seems to be getting better and better. http://icsharpcode.net/OpenSource/SD/ ...
2
by: ljgomez | last post by:
Hi everyone I just starting to develop in AJAX and I'm very interested in develop over PHP & Javascript. My question is about witch tools do you use for it. I'ven seen Zend Studio and someone...
16
by: Rainer Queck | last post by:
Hi, What would be the best way to develop a class library? I am planing to develop a couple of classes, needed in our company enviroment. These classe will be later used in several projects. ...
11
by: Michael | last post by:
I'm new to PHP, I already learned the basics of the language and built some little app's for practice. I have a critical dilemma, soon enough, I probably start to develop real-world...
0
by: geshan | last post by:
Lets see and compare the 4 ways (not tools) to develop/code your own PHP website or web application. The following are the ways you can code/develop your application (involving more Create Read...
1
by: pavanip | last post by:
Hi, Here requirement is we have to develop add-on to internet explorer and mozilla firebox. If we develop in dotnet it will not work with out having Dotnet frame work here all users no need to...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.