Showing posts with label resolve. Show all posts
Showing posts with label resolve. Show all posts

Wednesday, March 28, 2012

AJAX breaks AdRotator control rendering

Hi,

Does anyone know how to resolve the issue I'm experiencing with AJAX breaking the AdRotator control?

My AdRotators reside in a master page and display fine until a AJAX UpdatePanel is introduced. Once an UpdatePanel is added the AdRotators start to render their HTML output at the very beginning of the page's HTML (before the

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
in my case).

Image without AJAX problem:http://x.yougodo.com/screenshot-good.jpg

Image with AJAX problem:http://x.yougodo.com/screenshot-bad.jpg

Any help would be greatly appreciated.

Cheers

I can't seem to find any other users with your issue. You may want to give this approach a try:http://www.seesharprun.net/2007/08/09/AnAdrotatorAlternative.aspx. Where is your AdRotator located on your MasterPage? I'm assuming you are adding your UpdatePanel inside the Master's ContentTemplate?

Perhaps you can post a small snippet of code that will replicate the issue?

-Damien


Hi Damien,

Thanks for your suggestion, much appreciated - I will take a look.

Was puzzled myself why no-one else seemed to have encountered the same problem?!?

The UpdatePanel is actually located in the *.aspx page rather than the *.master - I'll try and create a small example to re-create later as everything is too intertwined in my current project to post something useful.

P.S. The Google Ads in the screenshots are not in AdRotators, only the image ads you see.


How bizarre... I've not been able to recreate problem creating a simple AJAX / master page scenario?!?

Maybe it's down to some of my non-standard controls - all pages are inherited from my own Page class that adds a bunch of extra properties and methods useful for my project. The control triggering the AJAX callback is also my own roll-your-own page number selecting control.

Quite puzzled as both these own-code-rolled controls successfully use AJAX functionality on other pages. It's jut when the AdRotator is introduced that bizarre results occur. Quite puzzled!


That's interesting that you can't reproduce it. I think your assumption may be correct with your non-standard controls. Do you perhaps have an un-closed element or something? This could be causing some issues. You also may just want to make sure your AJAX environment is setup correctly, you can refer to these common problems/fixes:http://blogs.visoftinc.com/archive/2007/09/23/asp.net-ajax--updatepanel-not-working--common-problems.aspx.

Hope you find your problem!

-Damien


Hi Damien,

Cheers once again for your help - much appreciated. Doesn't seem to be any of the issues described in the link you gave though.

Very bizarre, the output would suggest that somehow the AdRotator is getting to render it's output before the *.master or *.aspx files do?!? No html at all is output to the locations where the AdRotator is placed, only at the top of the page before all other html. Very puzzling.

I've abandoned trying to find a solution for now, coding my own temporary random ad selector for now. The AdRotators were only ever going to be a temporary measure until a fully functioning ad management system is plugged in.

Gavin.

Saturday, March 24, 2012

ajax and linkbutton problem, it is difficulty ,i cannot resolve it , help me

I use Asp.net Ajax exten1.0 encounter some question,so I need your help

My problem is :

I use two UpdatePanel in one aspx ,we can call left panel ,and right panel

At right panel ,I need to automatism make a server table ,and in every table cell ,I must bind a linkbutton in there , as linkbutton , the linkbutton text data is from database, linkbutton bind it ,and linkbutoon commandArgument are bind data also ,

now , I encounter problem is , when I click linkbutton , but not trigger linkButton _command this Event ,so I cannot get commandArgument value.to diplay at updatepanel1 ,but ,I assurance I register this Event , when the linkbutton automatism make ,sure I use this method

eg:

lnkButton =New LinkButton() ' add Event

AddHandler lnkButton.Command,AddressOf lnkButton_Command

eg : add trigger

Dim trigger As AsyncPostBackTrigger = New AsyncPostBackTrigger() trigger.ControlID = lnkButton.ID UpdatePanel2.Triggers.Add(trigger) I Add tirggers but , in html source I cannot find like these code , Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1','tUpdatePanel2'], ['btnConfrim','CalendarSelect','k0_0_0_0','k0_0_0_1','k0_0_0_2','k0_0_0_3','k0_0_1_0','k0_0_1_1','k0_0_1_2','k0_0_1_3','k0_0_2_0','k0_0_2_1','k0_0_2_2','k0_0_2_3','k0_0_3_0','k0_0_3_1','k0_0_3_2','k0_0_3_3','k0_1_0_0','k0_1_0_1','k0_1_0_2','k0_1_0_3','k0_1_1_0','k0_1_1_1','k0_1_1_2','k0_1_1_3','k0_1_2_0','k0_1_2_1','k0_1_2_2','k0_1_2_3','k0_1_3_0','k0_1_3_1','k0_1_3_2','k0_1_3_3','k0_2_0_0','k0_2_0_1','k0_2_0_2','k0_2_0_3','k0_2_1_0','k0_2_1_1','k0_2_1_2','k0_2_1_3','k0_2_2_0','k0_2_2_1','k0_2_2_2','k0_2_2_3',This 'k0_2_0_3' is linkbutton ID , That is why , thank you for your help

Your English is a bit shaky, so it was difficult to decipher exactly what is going on. However, one thing for sure that you are doing wrong is that you cannot create triggers programmatically. That is stated in the UpdatePanel Class page. If you simply use the ChildrenAsTriggers property set to true which is default, then when a link is clicked it will trigger the UpdatePanel update. However the issue of the command argument not available can be a bit more complex. It depends on the order of events and that is too complex to anayze without a simplified version of your code posted here. (Use the code editor button above to paste it a bit more neatly).

An example of why this might be necessary is that the order of page events can be affected by what is done during the page life cycle. For example I have seen the order of 2 events reverse simply by doing a FindControl or not in a method. There are muliple points in the life cycle where a control can Bind for instance and it may in fact Bind multiple times without you knowing it. That's just the way it works.

I would suggest that you add a Trace to all relevant events and check the order of events as that can sometimes give you insight. I have a very complex GridView run in Ajax, and without Trace events, I never would have been able to figure out what was wrong during edit with 2 way binding templates, column re-ordering, multi-column sorting, paging, etc all of which occur with Ajax.


sorry , my english is very poor.

my code is :

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load createTable()End Sub'Public Sub createTable()For iAs Integer = 0To 5Dim rowAs TableRow =New TableRow()For jAs Integer = 0To 6Dim cellAs TableCell =New TableCell() cell.Controls.Add(CreatePerSolt(i, j)) row.Controls.Add(cell)Next tabShecule.Controls.Add(row)Next End Sub Public Function CreatePerSolt(ByVal iAs Integer,ByVal jAs Integer)As TableDim tabAs Table =New Table tab.ID = i &"_" &"_" & jFor kAs Integer = 0To 3Dim rowAs TableRow =New TableRow()For hAs Integer = 0To 3Dim cellAs TableCell =New TableCell() lnkButton =New LinkButton() lnkButton.Text ="k" & i &"_" & j &"_" & k &"_" & h lnkButton.ID ="k" & i &"_" & j &"_" & k &"_" & h lnkButton.CommandArgument ="k" & i &"_" & j &"_" & k &"_" & hAddHandler lnkButton.Command,AddressOf lnkButton_CommandDim triggerAs AsyncPostBackTrigger =New AsyncPostBackTrigger() trigger.ControlID = lnkButton.ID trigger.EventName ="Click" UpdatePanel2.Triggers.Add(trigger) cell.Controls.Add(lnkButton) row.Controls.Add(cell)Next tab.Controls.Add(row)Next Return tabEnd Function Protected Sub lnkButton_Command(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.CommandEventArgs)Handles lnkButton.Command Label18.Text = e.CommandArgument.ToString()End Sub

I think you have to try this a different way to start.

http://www.asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_UpdatePanel.aspx

Please note the following statement:

You can add anUpdatePanel control programmatically, but you cannot add triggers programmatically. To create trigger-like behavior, you can register a control on the page as an asynchronous postback control. You do this by calling theRegisterAsyncPostBackControl(Control) method of theScriptManager control. You can then create an event handler that runs in response to the asynchronous postback, and in the handler, call theUpdate() method of theUpdatePanel control.

However because your table is inside the UpdatePanel, if you have ChildrenAsTriggers default set to true,all the LinkButtons should trigger an update without needing to register them. Just remove the trigger code. Once that is done if you still do not get a CommandArgument, post the UpdatePanel markup so that this can be duplicated.