Showing posts with label master. Show all posts
Showing posts with label master. Show all posts

Wednesday, March 28, 2012

AJAX UpdatePanel works on dev machine but still flickers on web server.

Hi Guys,

I have a master page, that has a ScriptManager and some "RoundCorner" controls. I also have a child page with a textbox and a FormView.

So I created an UpdatePanel, put my FormView inside the ContentTemplate, created the trigger and assigned to the TextBox's TextChanged event. (to an Async trigger).

When I run the app on the dev machine, it works wonders, no flickering and only the formview gets "refreshed". But as soon as I upload the code to the WebServer, the entire page gets refreshed everytime I change the value on the TextBox.

Am I forgetting to have something setup on the server side? I didn't find a "Deployment guide" for AJAX (If theres one, please point me to the right direction), so I figured that installing the MS Ajax 1.0 on the server would do it.

Thanks!

Marcelo

More info:

Just tried a small example, and again it does not work on the server side (both dates get updated):

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="TestPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server">From here, it is inside the panel <br /> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <asp:UpdatePanel runat="server" ID="UpdatePanel1"> <ContentTemplate> <asp:Label ID="TestLabel" runat="server" Text=""></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel><hr/>From here down its not inside the Panel<br /> <asp:Label id="Test2Label" runat="server" text="" /> <asp:Button ID="Button1" runat="server" Text="ClickHere" /> </form></body></html>

***********CS content

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass TestPage : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) {TestLabel.Text = DateTime.Now.ToString();Test2Label.Text = DateTime.Now.ToString(); }}

Anyone has ideas?

Thanks!

Marcelo


Nobody at all?


Hello,

Take a look at my post and the solution we found:http://forums.asp.net/thread/1649057.aspx

Possibly your case is similar.


Hi there,

At first it seemed that I had my problem solved, since the properties show exactly the same as yours.. So I tried to change the property to true, but no luck, it still does a full refresh on the

server side..

I checked your sample site, and I it does a full refresh aswell.. what part of if should do a partial refresh?

Could you send me the code you have on your page Init?

this is what I've added on mine:

private void Page_Init(System.Object sender, System.EventArgs e) { ScriptManager1.SupportsPartialRendering =true; }

I'm getting frustrated with this...


Hi,

The partial refresh on our page (http://beta.easyquerydemo.com) works only for "Result" panel (at the bottom of the page). If you define some query using "Conditions" panel (for example: "Customer Company Name starts with A") and then click on "Update Result" button the result set should appear almost immediately and without updating the whole page.

As for code: we use exactly the same line of code as you published in your previous post.

Did you check the value of this property after assignment. Maybe it still is set to 'false' because of some limitations in browser which you use to access this page.


In this example of yours, both Labels get updated because you update the datetime in your Page_Load function.

Your Page_Load function should be like this:

Protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
TestLabel.Text = DateTime.Now.ToString();
Test2Label.Text = DateTime.Now.ToString();
}
}

And your button to update the Label inside the updatepanel should call a function to update the datetime of that label.

Protected void UpdateLabel(object sender, eventargs e)
{
TestLabel.Text = DateTime.Now.ToString();
}


Hi,

What i'm doing is the following, on page_init i force the property to be true, and on page load i load all those variables into labels, just like you do on your sample site. It does in fact change that property to True. but the full refrensh still occurs.

Now I see the part that uses the update panel (The result on your site). And it actually works.

Do you have any other hint?

Correct me if I'm wrong but, theSupportsPartialRendering property is set based on:EcmaScriptVersion,SupportsCallback andW3CDomVersion; which are properties of HttpBrowserCapabilities that is assigned from a Request.Browser object.

That means that it is checking the Client's Browser capabilities, and nothing to do with the server itself right? If thats true, as long I use the same browser (IE7 for instance) it should not matter where that page is sitting at, it should bring the same value for SupportsPartialRendering...

Is my line of thought correct or I am missing something ?

Thanks a lot for the help you are giving me!


Hi there,

1. About "other hint". No I do not have it unfortunately. The only one thing I can suggest is to try add another UpdatePanel on your page and some simple controls into it (e.g. one button and one label) just for testing and see how it works. Another good idea will be to create another simple testing page using AJAX template in Visual Studio (if you use it) and see how it works on your server.

2. About the properties whichSupportsPartialRendering is based on: yes you are right, at least we understand this part of documentation exactly the same way.

Possibly we should send this request to Microsoft? There must be more conditions for partial rendering support except those ones described in documentation. I think there must be some requirements for server side.



Hey,

I will create a brand new example using the AJAX project template and report back my findings.

I agree, but I never done this before. Usually I can find a work-around for these type of issues, which doesn't seem to be the case right now. How should I proceed on submiting this to MS?

Regards


Hi again there,

More findings:

1. I created a brand new application and used the same sample as before, but this time I added the labels and forced SupportPartialRendering to true.

Amazingly the application worked just fine on the server side.

2. I've added a master page to this application and wired up the old "default.aspx" to the master page, moving the ScriptManager to the master page (and also the SupportPartialRendering portion)

Application stopped working.

3. I moved the ScriptManager (and SupportPartialRendering) back to the Default.aspx and removed from the master page.

Application still didn't work.

At this point I think is safe to conclude that: UpdatePanels will not work with master pages!!!?

PS: All the 3 situations work fine on the development machine.

Anyone has Master Pages + Update panels working properly on a production server?


We finally have solved the same problem. I think your case is similar.

Seehttp://forums.asp.net/thread/1653605.aspx for more info.


Hi korzh,

This is great, now it works like a charm! Thanks a lot for keeping me posted! Now, where in the documentation does it show anything about that property.. :P only a insider would know about it ..

Thanks a lot! Case closed!

Marcelo


Hi korzh,

This is great, now it works like a charm! Thanks a lot for keeping me posted! Now, where in the documentation does it show anything about that property.. :P only an insider would know about it ..

Thanks a lot! Case closed!

Marcelo

AJAX Update Panel Issues with Master Pages

Hello all, I am having issues using AJAX on my aspx content pages. I have a Master Page that contains a Script Manager and I want to use an Update Panel on some of my content pages. When I do this my aspx content page does not recogize any element on the page that is in the Update Panel, nor does it recognize the Update Panel. It underlines every control on the page and displays "unknown element" errors. I can still build my solution and run the app with no problems, and the AJAX seems to function correctly, but when I view the source code of the aspx page I get errors. If I try and change properties in Design view my Visual Studio locks up. If I use an Update Panel or any other Ajax extensions on a page that is not a content page of a Master Page everything works perfectly.

Is this a common problem with Master Pages? Is there a solution? I tried to search for this problem but did not turn many results. Any help or direction would be appreciated! This makes it very hard to develop. I am using Version 1.0 of ASP.Net AJAX.

Yes it is an issue a lot of people see I would assume. I just answered another post in regards to this here

http://forums.asp.net/thread/1623913.aspx

AjaxButter


Installing SP1 for Visual Studio 2005 fixed this problem.

Ajax update panel focus problem

Hi

I have a asp.net 2 web app that uses asp.net ajax and master pages. I have a very common problem that I think most people get when using an update panel and textboxes. The tab order after leaving the text box is lost, so I have heard the fix is to use

Me.ScriptManager1.SetFocus(Textbox1.ClientID);

Rather than adding the ScriptManager to every page I have added it to my Master page. However my update panel exists within a user control, which is then embeded in a master page. So the above syntax does not work in my user control as it does not know about the ScriptManager as it is defined in my master page.

Any ideas on how I could get this to work? Or any other methods to get round this textbox focus problem?

Many thanks inadvance

Use ScriptManager.GetCurrent() to get a reference to the page's ScriptManager.


See for more detail.

http://asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_SetFocus.aspx


Hi,

You may get reference to the scriptManager instance via
ScriptManager.GetCurrent(this.Page)

Hope this helps.


I'm having a similar problem, except that I have a timer that refreshes some content every 4 seconds. I set the

this.ScriptManager1.SetFocus(tbMessage.ClientID);

but when the content refreshes, it sends the cursor to the beginning of the text box. Even when i'm in the middle of typing something.Tongue Tied

Is there a way to keep the cursor exactly where it was when content was updated in the update panel?

- Albert

(PS - Sorry to hijack this thread.)

Monday, March 26, 2012

AJAX Toolkit Modal Popup Extender - Display Issue

I have a site that is using a master page. Within the master page is a div that has a style sheet entry setting the position to absolute. The content div is within this div. My problem is that when the modal popup is displayed and the user has the screen resolution is set to 800X600 the bottom of the modal popup is off of the screen and as the user scrolls down the page the modal dialog moves along with the scrolling keeping the bottom of the dialog off of the page. I tried setting the X/Y parameters for this but as the user scrolls the dialog box still moves, keeping part of it off of the viewable area of the screen. I remove the position absolute setting in the style sheet for the parent div and this issue does not occur, but, my screen is not displayed correctly. This is using IE6. Any ideas?

Thank You for any help.

Actually I was incorrect. It was not the position=absolute causing the error. It was the top=167px that is causing the error. Top is not applied if the position is not specified. That is the root cause of the issue. Please reply if you have a solution.

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.

Wednesday, March 21, 2012

Ajax tabContainer doesnt dispaly good

Hi! I dropped a ajax tabcontainer in master page, but it's not displaying good. I have this in masterpage:

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

Thank you for the help here, been truggling with this for 2 days.

Hi James25,

Would you please give more information ? We cannot find out the exact root cause based on your description.

Best regards,

Jonathan.


Hi! Thank you for the reply! The cause is the Doctype:

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If I leave it on the page the tabcontainer gets displayed good. If I take it off the tabcontainer gets broken. But, again if I don't put the doctype the footer takes up half the page.

AJAX Tab Control & the menu control

Hi,

I have a Master Page with a menu control & a Tab Control on a aspx form that will be displayed as a Content.

How do I switch between the Tab Control when a click is made on the menu in the master pages?

Do you want to set the currently selected tab panel?

TabContainer1.ActiveTab = TabPanel1;

Im accessing the TabControl on the Default.aspx & this code does not work. I get no errors thou. Am I doing something wrong?

protectedvoid MenuItem_Click(object sender,MenuEventArgs e)

{

if (this.Menu1.SelectedItem.Value.Equals("1"))

{

TabContainer myTabContainer = (TabContainer)this.ContentPlaceHolder1.FindControl("TabContainer1");

TabPanel myTabPanel2 = (TabPanel)this.ContentPlaceHolder1.FindControl("TabPanel2");

myTabContainer.ActiveTab = myTabPanel2;

}

}


Try this:

protectedvoid MenuItem_Click(object sender,MenuEventArgs e)

{

if (this.Menu1.SelectedItem.Value.Equals("1"))

{

TabContainer myTabContainer = (TabContainer)this.ContentPlaceHolder1.FindControl("TabContainer1");
myTabContainer.ActiveTab = TabPanel2;

}

}


I got it working with this

using AjaxControlToolkit;

protectedvoid Menu1Item_Click(object sender,MenuEventArgs e)

{

AjaxControlToolkit.

TabContainer tc = (AjaxControlToolkit.TabContainer)this.ContentPlaceHolder1.FindControl("TabContainer1");if (this.Menu1.SelectedItem.Value =="1")

{

AjaxControlToolkit.

TabPanel tp = (AjaxControlToolkit.TabPanel)tc.FindControl("TabPanel1");

tc.ActiveTab = tp;

}

if (this.Menu1.SelectedItem.Value =="2")

{

AjaxControlToolkit.

TabPanel tp = (AjaxControlToolkit.TabPanel)tc.FindControl("TabPanel2");

tc.ActiveTab = tp;

}

}