?
Solved

Problem with javascript and UpdatePanel

Posted on 2008-06-17
1
Medium Priority
?
1,338 Views
Last Modified: 2012-06-21
I am having a problem with javascript, an UpdatePanel, and a textbox.   Basically, everything is working fine except that when the event from the textbox gets triggered, it does a full page reload instead of an ajax style update.  The code is below.  I can't seem to find the bug, hopefully someone here can.  this is the code which creates the update panel, the textbox and the events.  All i want this to do is every time someone something in the textbox, it refreshes the date.
TextBox box = new TextBox();
            box.ID = "box";
            box.TextChanged += new EventHandler(this.box_TextChanged);
            box.Attributes.Add("onKeyUp", "javascript:__doPostBack('box','')");
            
            AsyncPostBackTrigger boxtrigger = new AsyncPostBackTrigger();
            boxtrigger.ControlID = "box";
            boxtrigger.EventName = "TextChanged";
 
            UpdatePanel panel = new UpdatePanel();
            panel.ID = "UpdatePanel1";
            panel.ChildrenAsTriggers = true;
            panel.UpdateMode = UpdatePanelUpdateMode.Conditional;
            panel.Triggers.Add(boxtrigger);
            panel.ContentTemplateContainer.Controls.Add(box);
            panel.ContentTemplateContainer.Controls.Add(new LiteralControl(DateTime.Now.ToString()));

Open in new window

0
Comment
Question by:Metsfan92286
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
ajitha75 earned 500 total points
ID: 21809768
Is this residing inside a user control. One thing you wan to check is that ClientID and ID of box are same. If they are not, then you have to ensure that you pass the ClientId for the below assignment

box.Attributes.Add("onKeyUp", "javascript:__doPostBack('box','')");

you can change it to

box.Attributes.Add("onKeyUp", "javascript:__doPostBack('" + box.ClientID +"','')");
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question