Showing posts with label properly. Show all posts
Showing posts with label properly. Show all posts

Monday, March 26, 2012

Export to Microsoft Excel

Hello,
IE Functionality of Exporting tables to Microsoft Excel doesn't work properly when used with Asp.NET AJAX,

it always exports the first loaded data ignoring any updates done through AJAX Asynchronous post back

i.e. if a page is loaded with data X and then updated using AJAX update panel and
returned data Y then using Export to Microsoft Excel on this page will export
the first data X and not data Y


how can this be fixed?

Appreciate your help in advance.

maybe you can put some code here so that we can know what actually happen.

currently it work fine to me


Hello,

This is a sample of the code unfortunately i wanted to upload the solution but was not able to add files.

I have a master page, default.aspx and dataclass.cs

Appreciate your help in advance.

"C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
"Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> "ScriptManager1" runat="server">
"DropDownList1" runat="server" AutoPostBack="True"> A B

"UpdatePanel1" runat="server"> "GridView1" runat="server" DataSourceID="ObjectDataSource1"> "ObjectDataSource1" runat="server" TypeName="DataClass" SelectMethod="FillData"> "DropDownList1" Name="text" PropertyName="SelectedValue" Type="String">

using System;using System.Data;using System.Configuration;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 _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e){if(!IsPostBack)DropDownList1.SelectedIndex = 1;}}public class DataClass{public DataClass(){//// TODO: Add constructor logic here//}public static DataTable FillData(string text){DataTable dt =new DataTable();dt.Columns.Add("Column");for (int i = 0; i < 100; i++){dt.Rows.Add(new object[] { text });}return dt;}}

Saturday, March 24, 2012

Events not firing on custom control inside FormView inside UpdatePanel

Hi all-

I have a custom control that I have been using inside a FormView; all its events have been firing properly. Recently I placed the FormView inside an UpdatePanel, and now the events of the control are not firing.

I set the AutoPostBack property of the control to True and even turned on AutoEventWireup, but the event doesn't fire.

I tried adding the control as a Trigger on the UpdatePanel using this syntax:

<asp:AsyncPostBackTriggerControlID="FormView1:CustomControl1"EventName="SelectionChanged"/>

but the event still doesn't fire.

Am I doing this the right way? I have also posted this question on the control vendor's forum, but I thought I'd check here as well, to make sure I'm doing everything else right.

Thanks for any help...

-Andrew

Hi Andrew,

Can you post a small but full sample? It's preferred that this sample doesn't rely on a specific class or database( Use mock data created in memory instead? ) .


No,

"FormView1:CustomControl1" is not the right way, In this scenario,I think you can use FindContorl method(for more information,seehttp://forums.asp.net/t/1107107.aspx).

TheRegisterAsyncPostBackControl(Control) method enables you to register controls to perform an asynchronous postback instead of a synchronous postback which updates the entire page . When theChildrenAsTriggers property of anUpdatePanel control is set totrue (which is the default), postback controls inside theUpdatePanel control are automatically registered as asynchronous postback controls and cause a refresh of the panel content.

Use theRegisterAsyncPostBackControl(Control) method to register controls outside of anUpdatePanel control as postback controls that can perform asynchronous postbacks and potentially update the content of an update panel. To update anUpdatePanel control programmatically, call theUpdate() method.

For more information,seehttp://www.asp.net/AJAX/Documentation/Live/mref/M_System_Web_UI_ScriptManager_RegisterAsyncPostBackControl_1_62fe17e7.aspx.

Best Regards,


Hi gentlemen-

I just created a simple version of the page, and everything is working. So the problem has to be somewhere in my page. Now that I know that, I believe I can figure out the rest on my own.

Thanks for your time; next time I will just try a simplified version first!

Thanks,

-Andrew


Hi,

It is a good manner to try a simplified version first when you run into an issueSmile

Best Regards

Wednesday, March 21, 2012

Errors with UpdatePanel & WebPart stuff after upgrade

I recently upgraded from Atlas CTP to Ajax beta 1. I beleive that I properly updated my web.config et. al.; however I keep getting this error regarding the UpdatePanel:

Element 'UpdatePanel' is not a known element. This can occur if there is a compilation error in the Web site.
Element 'AsyncPostBackTrigger' is not a known element. This can occur if there is a compilation error in the Web site.
Validation (XHTML 1.0 Transitional): Element 'Triggers' is not supported.
Validation (XHTML 1.0 Transitional): Element 'ContentTemplate' is not supported.

I can drag the UpdatePanel from the IDE toolbox onto the page, but the Intellisense doesn't work and it causes errors.

On a related note, none of my WebParts stuff is recognized either:

Element 'WebPartManager' is not a known element. This can occur if there is a compilation error in the Web site.
'WebPartZone' is not a known element. This can occur if there is a compilation error in the Web site.

Anyone know what is causing this, and how I can fix?

TIA

hello.

hum...have you changed the web.config entries on the page section?


I've got the same problem. My web.confg page section looks like this:

<system.web><pages><controls>

<addtagPrefix="asp"namespace="Microsoft.Web.UI"assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addtagPrefix="asp"namespace="Microsoft.Web.UI.Controls"assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addnamespace="Microsoft.Web.Preview.UI"assembly="Microsoft.Web.Preview"tagPrefix="atlas"/>

<addnamespace="Microsoft.Web.Preview.UI.Controls"assembly="Microsoft.Web.Preview"tagPrefix="atlas"/>

</controls>

I should be using <asp:UpdatePanel...> NOT<atlas:UpdatePanel...> correct? The only items showing up w/ intellisense are <atlas:AutoCompleteExtender>,<atlas:DragOverlayExtender>,<atlas:ProfileService>,<atlas:Script>,<atlas:TimerControl>, and<atlas:UpdateProgress>.

I'm also a bit lost with what I should have in my toolbox after the migration and adding in the value-add controls. Currently, I still have the ATLAS controls in my toolbox, same as I did from before the migration. Should I have removed these? I also removed the .dll's from my BIN directory before the migration (before the installs) and then added back both "AjaxControlToolkit.dll" and "Microsoft.Web.Preview.dll" after the BETA+ValueAdd+Toolkit installs.

Please help, I am LOST! Thanks!!

--c--


Change you asp tags to something else (Atlas" or "ajax" or whatever... will fix it - its a known bug...

Thanks Jody, that did it!!

Someone should consider updating the Migration Guide document. Step #3 specifically says to use "asp" for the tag. After I had already renamed all my <atlas> tags to <asp> I had to go back and put them back :( ...what a pain.

Thanks again!


Thanks Jodi. That helped me a lot. Just a note here. Change the tag prefix in web.config file pages section as well as in the html design file.

Shaun


I have the same error with the installation of AJAX 1.0, without any beta version installed , and the solution was the same, I changed the tags in the web config and in the html and the problem was solved.


Hi,
I don't know to wich categories this belongs butSmartNavigation="true" seems to cause also a "Sys.WebForms.PageRequestManagerParserErrorException" also.

Just some tip if you looking for hours just as I did ;)

Grtz


I've heard that you do not use SmartNavigation with AJAX (or even VS2005)