How to develop

Discussion in 'ASP .Net' started by Peter, Jul 30, 2008.

  1. Peter

    Peter Guest

    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, Jul 30, 2008
    #1
    1. Advertising

  2. Peter

    Munna Guest

    Hi,,

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

    Best of luck

    Munna
    Munna, Jul 30, 2008
    #2
    1. Advertising

  3. 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:
    .
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: "Peter" <>
    >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], Jul 30, 2008
    #3
  4. Peter

    Peter Guest

    Thank you!

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

    "Steven Cheng [MSFT]" <> wrote in message
    news:...
    > 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:
    > .
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    > --------------------
    >>From: "Peter" <>
    >>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, Jul 30, 2008
    #4
  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:
    .

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

    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: "Peter" <>
    >References: <>

    <>
    >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]" <> wrote in message
    >news:...
    >> 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], Jul 31, 2008
    #5
  6. 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:
    .

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

    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: "Peter" <>
    >References: <>

    <>
    >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]" <> wrote in message
    >news:...
    >> 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], Jul 31, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bXRlcm1vdWw=?=

    Can you develop .NET apps for IPOD OS

    =?Utf-8?B?bXRlcm1vdWw=?=, Jul 1, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    535
    =?Utf-8?B?bXRlcm1vdWw=?=
    Jul 1, 2005
  2. Replies:
    0
    Views:
    500
  3. Jessica Weiner

    can i use vs .net to develop win32 apps?

    Jessica Weiner, Dec 17, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    696
    Pascal Duti
    Jan 6, 2006
  4. Michal A. Valasek
    Replies:
    1
    Views:
    373
    Don Chen
    Aug 9, 2003
  5. MS News \(MS ILM\)
    Replies:
    0
    Views:
    343
    MS News \(MS ILM\)
    Aug 9, 2003
Loading...

Share This Page