By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,606 Members | 3,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,606 IT Pros & Developers. It's quick & easy.

ajax help - populating a text field

P: 5
I am not sure if this goes in here ot the ASP forum


I have been trying to get some simple AJAX on my site but its not going so well
I am not sure what my problems is what i am trying to do is populate a text field

Here is my code



--------------------------------------------------------------------------------

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="_test_Default5" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6.  
  7. <head runat="server">
  8.  
  9. <title>Untitled Page</title>
  10.  
  11. <script language="javascript" type="text/javascript">
  12.  
  13. function fadeout(text){
  14.  
  15. alert(text);
  16.  
  17. text.style.filter="blendTrans(duration=2)";
  18.  
  19. text.filters.item(0).Transition=12;
  20.  
  21. // doFilter(text)
  22.  
  23. }
  24.  
  25.  
  26. function doFilter (text) {
  27.  
  28. filterFrom.filters.item(0).Apply();
  29.  
  30. text.filters.item(0).Transition=12; // 12 IS THE DISSOLVE FILTER
  31.  
  32. text.style.visibility = "hidden";
  33.  
  34. filterTo.style.visibility = "";
  35.  
  36. filterFrom.filters.item(0).play(14);
  37.  
  38. }
  39.  
  40.  
  41. </script>
  42.  
  43. </head>
  44.  
  45. <body>
  46.  
  47. <form id="form1" runat="server">
  48.  
  49. <asp:ScriptManager ID="ScriptManager1" runat="server">
  50.  
  51. </asp:ScriptManager>
  52.  
  53.  
  54.  
  55. <asp:DropDownList ID="quataty" runat="server" AutoPostBack="True" 
  56.  
  57. onselectedindexchanged="quataty_SelectedIndexChanged" >
  58.  
  59. <asp:ListItem Value="25" Text="25"></asp:ListItem>
  60.  
  61. <asp:ListItem Value="50" Text="50"></asp:ListItem>
  62.  
  63. <asp:ListItem Value="75" Text="75"></asp:ListItem>
  64.  
  65. <asp:ListItem Value="100" Text="100"></asp:ListItem>
  66.  
  67. <asp:ListItem Value="200" Text="200"></asp:ListItem>
  68.  
  69. <asp:ListItem Value="300" Text="300"></asp:ListItem>
  70.  
  71. </asp:DropDownList>
  72.  
  73.  
  74. <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  75.  
  76. <ContentTemplate>
  77.  
  78. <asp:Label ID="total" runat="server" Text=""></asp:Label>
  79.  
  80. </ContentTemplate>
  81.  
  82. <Triggers>
  83.  
  84.  
  85. </Triggers>
  86.  
  87.  
  88. </asp:UpdatePanel>
  89.  
  90.  
  91.  
  92. <br /><br /><br /><br /><br /><br />
  93.  
  94.  
  95. <asp:Label ID="time" runat="server" Text=""></asp:Label>
  96.  
  97. </form>
  98.  
  99. </body>
  100.  
  101. </html>
  102.  
  103.  


--------------------------------------------------------------------------------


Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3.  
  4. using System.Collections;
  5.  
  6. using System.Configuration;
  7.  
  8. using System.Data;
  9.  
  10. using System.Web;
  11.  
  12. using System.Web.Security;
  13.  
  14. using System.Web.UI;
  15.  
  16. using System.Web.UI.HtmlControls;
  17.  
  18. using System.Web.UI.WebControls;
  19.  
  20. using System.Web.UI.WebControls.WebParts;
  21.  
  22. public partial class _test_Default5 : System.Web.UI.Page
  23.  
  24. {
  25.  
  26. protected void Page_Load(object sender, EventArgs e)
  27.  
  28. {
  29.  
  30.  
  31.  
  32. time.Text = "123";
  33.  
  34. }
  35.  
  36.  
  37.  
  38. protected void quataty_SelectedIndexChanged(object sender, EventArgs e)
  39.  
  40. {
  41.  
  42. total.Text = quataty.SelectedItem.ToString();
  43.  
  44. }
  45.  
  46. }
  47.  
  48.  
  49.  
Sep 24 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 392
What do you mean by "its not going so well "? What specifically is the problem? What is it doing or not doing? Errors?
Sep 25 '08 #2

Frinavale
Expert Mod 5K+
P: 9,731
What do you mean by TextField?
Are you talking about a Label?

You need to put all of the controls that are required to perform the partial page update inside the UpdatePanel.

Therefore if you are updating the Label based on what is selected in your DropDownList you need to put both the Label and the DropDownList inside the UpdatePanel.

You have to be more specific about what is wrong and what difficulties you are facing.

-Frinny
Sep 26 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.