Click here to Skip to main content
15,885,546 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Problem with Dropdownlist (DDL) box... Pin
<<Tash18>>27-Apr-10 21:22
<<Tash18>>27-Apr-10 21:22 
AnswerRe: Problem with Dropdownlist (DDL) box... Pin
nagendrathecoder27-Apr-10 21:27
nagendrathecoder27-Apr-10 21:27 
GeneralRe: Problem with Dropdownlist (DDL) box... Pin
<<Tash18>>27-Apr-10 21:43
<<Tash18>>27-Apr-10 21:43 
AnswerRe: Problem with Dropdownlist (DDL) box... Pin
Ankur\m/27-Apr-10 21:29
professionalAnkur\m/27-Apr-10 21:29 
GeneralRe: Problem with Dropdownlist (DDL) box... Pin
<<Tash18>>27-Apr-10 21:42
<<Tash18>>27-Apr-10 21:42 
AnswerRe: Problem with Dropdownlist (DDL) box... Pin
nagendrathecoder27-Apr-10 22:06
nagendrathecoder27-Apr-10 22:06 
AnswerRe: Problem with Dropdownlist (DDL) box... Pin
Mohammed Hameed28-Apr-10 2:58
professionalMohammed Hameed28-Apr-10 2:58 
QuestionASP.Net: Losing Javascript events on async postback Pin
Jake Slack27-Apr-10 10:53
Jake Slack27-Apr-10 10:53 
I am creating a ASP.Net server control to manage locations. The control is a composite control containing several text-boxes, labels, and a link button. I use the AJAX Control Toolkit to provide a modal popup which contains a Bing map. All the Javascript is in its own file and used as an embedded web resource.

The link button is what opens the modal popup. It also needs to call a Javascript function that initializes the Bing map (onclick = "GetMap();"). There are instances when this server control is placed within an Update Panel (and there is no way to avoid this). When in an Update Panel the link button loses its onclick event. I understand that this is because during an async postback the portion of the DOM that defines the content of the Update Panel is thrown out and reinitialized, resulting in the event breaking. When the control is not in an Update Panel everything works as intended.

I have tried registering events on Page.Load and Page.Init, like so:
link_FindLocation = new LinkButton(); 
link_FindLocation.OnClientClick = "GetMap();"; 
Page.Load += delegate(object sender, EventArgs args) 
{ 
    link_FindLocation.OnClientClick = "GetMap();"; 
};


I have also tried flat out writing the function call to the page:
link_FindLocation = new LinkButton();
 link_FindLocation.OnClientClick = "GetMap();"; 
link_FindLocation.Click += delegate(object sender, EventArgs args) 
{ 
   Page.Response.Write("<script type = \"text/javascript\">GetMap();</script>"); 
};


I have put breakpoints on the lines inside each delegate and they do not get hit. I am not aware of any special way to register events of a composite control's child control or the Page.Load/Page.Init events when being done inside a server control. Is there some special way to register these events? (Note: Both those code blocks above are in my CreateChildControls() method)

Below is the GetMap() Javascript function. As you can see it is pretty straight forward.
var map; 
function GetMap() 
{ 
   if (map != null) 
   { 
      map.Dispose(); 
   } 
   map = new VEMap('map'); map.SetDashboardSize(VEDashboardSize.Tiny);  
   map.LoadMap(new VELatLong(42.869925, -78.681335), 10); 
   map.Resize('440px', '360px'); 
   map.SetZoomLevel(12); 
}


Does anyone have a solution to Javascript events breaking after an async postback that can be applied to a server control? Everything needs to be done within the server control itself and not in the page that is using the control.
AnswerRe: ASP.Net: Losing Javascript events on async postback Pin
daveyerwin27-Apr-10 14:12
daveyerwin27-Apr-10 14:12 
GeneralRe: ASP.Net: Losing Javascript events on async postback Pin
Jake Slack28-Apr-10 2:09
Jake Slack28-Apr-10 2:09 
GeneralRe: ASP.Net: Losing Javascript events on async postback Pin
daveyerwin28-Apr-10 2:31
daveyerwin28-Apr-10 2:31 
QuestionItemTemplate can't find a control in placeholder Pin
mark_me27-Apr-10 9:44
mark_me27-Apr-10 9:44 
AnswerRe: ItemTemplate can't find a control in placeholder Pin
Jamil Hallal27-Apr-10 21:03
professionalJamil Hallal27-Apr-10 21:03 
GeneralRe: ItemTemplate can't find a control in placeholder Pin
mark_me28-Apr-10 11:40
mark_me28-Apr-10 11:40 
QuestionFree Online Test and Interview Questions Pin
Nikhil Bandekar27-Apr-10 7:11
Nikhil Bandekar27-Apr-10 7:11 
AnswerRe: Free Online Test and Interview Questions Pin
Sandeep Mewara27-Apr-10 18:56
mveSandeep Mewara27-Apr-10 18:56 
QuestionHow to align EmptyDataText in the middle of gridview Pin
Andraw11127-Apr-10 6:30
Andraw11127-Apr-10 6:30 
AnswerRe: How to align EmptyDataText in the middle of gridview Pin
RCoate27-Apr-10 17:01
RCoate27-Apr-10 17:01 
QuestionNamespace not exposed in aspx.cs file Pin
Adam Brown 327-Apr-10 6:00
Adam Brown 327-Apr-10 6:00 
AnswerRe: Namespace not exposed in aspx.cs file Pin
michaelschmitt27-Apr-10 7:01
michaelschmitt27-Apr-10 7:01 
AnswerRe: Namespace not exposed in aspx.cs file Pin
daveyerwin27-Apr-10 7:15
daveyerwin27-Apr-10 7:15 
QuestionListbox selecteditem not eqal to true [modified] Pin
Sandesh M Patil27-Apr-10 5:55
Sandesh M Patil27-Apr-10 5:55 
AnswerRe: Listbox selecteditem not eqal to true Pin
Not Active27-Apr-10 7:10
mentorNot Active27-Apr-10 7:10 
AnswerRe: Listbox selecteditem not eqal to true Pin
michaelschmitt27-Apr-10 7:16
michaelschmitt27-Apr-10 7:16 
AnswerRe: Listbox selecteditem not eqal to true Pin
nagendrathecoder27-Apr-10 20:01
nagendrathecoder27-Apr-10 20:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.