Solved

Problem with javascript and UpdatePanel

Posted on 2008-06-17
1
1,337 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 125 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

728 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