Showing posts with label masterpage. Show all posts
Showing posts with label masterpage. Show all posts

Monday, March 26, 2012

AJAX Timer, UpdatePanel and AdRotator problem

Hi,

I try to use an AJAX updatepanel with a timer and a AdRotator on my MasterPage and my search engine stop working fine when the timer update the updatepanel.

I have some links who gives parameters to my search engine (like : ...find.aspx?search=0&TS=1&Sort=date_de&D=1000000&CP=&QPP=5&Cat=12000&SubCat=0&T=131400)

But when the timer update the updatepanel (so the AdRotator too), if i click again on these links, the search engine return no results...

Very strange behavior...

Someone have an idea why this happen with these AJAX controls?

Thanks

My code :

...
<td align="center" style="border-bottom: lightgrey thin dotted">
<asp:Timer ID="Timer1" runat="server" Interval="15000">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanelAdRotator" runat="server" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
</Triggers>
<ContentTemplate>
<asp:AdRotator ID="AdRotator1" runat="server" Height="60px" Width="468px" BorderColor="Black"
BorderStyle="Solid" BorderWidth="1px" DataSourceID="XmlDataSource1" Target="_blank" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/ads.xml"></asp:XmlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</td>
...

Hi,

Can you be more specific about how do you implement the search engine?

Does the link's url remain valid after the updatePanel updates?


Hi,

my search engine is a Stored Procedure that gets the results from a SQL 2005 database.

I call the Stored procedure at page load (search.aspx) with the parameters who are passed from the previous page.

Exemple : search.aspx?search=nintendo&TS=1&Sort=date_de&D=1000000&CP=&QPP=5&Cat=0&SubCat=0&T=131400


Do those query strings still exist after the updatePanel updates?

Saturday, March 24, 2012

Ajax Timer in Master Page Configuration

Hi All,

My requirement is like displaying random advertisements in masterpage. I had a page with Ajax Timer control which on Timer_Tick event fetches me a new image and bind to <asp:hyperlink>, my problem is on page_load also i want to display image, but image is displayed only on Timer_Tick after some fixed 3000 seconds is elapsed. On page_load i want to display same images, my images are dynamic comes from database, i store them in a dataset, and binds to asp:hyperlink on timer_tick. Can anyone help, on how to display image on page_load, is there any way how i can attach the server side event (Timer_Tick) on page_load also, so that it will fetch me the image.

Thanks In Advance,

Karthikeyan.

You could invoke your Timer_Tick method from within your Page_Load method. The following example assumes your asp:Hyperlink is called "adLink" and that your AJAX Timer is called adTimer.

To be more thorough, I am performing a check on the first load of the page (not subsequent post backs) to see if the adLink has not had it's url or Image url specified... as such, make sure you deliberately leave these attributes empty when you define your asp:Hyperlink in your aspx page.

1protected void Page_Load(object sender, EventArgs e)
2{
3if (!Page.IsPostBack)
4 {
5// Initialise the ad for first load (if needed).6if (adLink.NavigateUrl.Equals(string.Empty) && adLink.ImageUrl.Equals(string.Empty))
7 {
8 adTimer_Tick(adTimer,null);
9 }
10 }
11}
1213protected void adTimer_Tick(object sender, EventArgs e)
14{
15// Your current code that specifies the ad image and url.16}

Hope this helps,

Tones.


Hi Tony,

Thanks for your valuable reply, my solution is solved, but i had a question, where, my code looks like this,

Public lobjDSetDataAs DataSet -> Global Dataset

Page_Load()

pvGetBannerImages -> This function will go query the images and get the images from the database.

If Not Page.isPostBack Then

pvShowImages() -> This function will get image one by one for a fixed ajax timer intereval 3000 seconds, and binds the image to hyperlink

End if

In aspx, my updatepanel will be like this,

<asp:UpdatePanelID="pnlBanner"runat="server"UpdateMode="Conditional">

<Triggers>

<asp:AsyncPostBackTriggerControlID="Timer1"/>

</Triggers>

<ContentTemplate>

<asp:HyperlinkID="hplAdImage"runat="server"Target="_blank">

<asp:ImageID="BannerImage"runat="Server"/>

</asp:Hyperlink>

<asp:HiddenFieldID="hdCount"runat="Server"/>

</ContentTemplate>

</asp:UpdatePanel>

My Problem is every time, the control is going to If Page.IsNotPostback, and querying the database, i don't want to query the database again, and getting the data back, binding to hyperlink after fixed 3000 milliseconds, is there any way through which i can avoid this database query, sometimes i am getting error like HTTP 500 error with Sys.Exception something like this. Can you help me on this, i thought of using caching but with ajax, is it possible, even if it possible, i had around 8 modules, where this banner will rotate, for each section different banner comes from database, i don't want to cache because it is dynamic data, can i use here SqlCacheDependency, if so can you guide me how to go on this,

Thanks In Advance,

karthikeyan.