Showing posts with label customer. Show all posts
Showing posts with label customer. Show all posts

Saturday, March 24, 2012

UpdatePanel and FileUpload

Hi,

i have wide customer table that i handle with a big DetailView nested inside an UpdatePanel for faster interaction. Works like a charm.

Now they ask me to allow the user to upload a file, but when i add it in the detail view and i save data i get no file at all, as if putting it into an updatepanel do not allow him to send the file any more.

Is there some setting i have to put so to make it work ?

thanks in advance,

Fabrizio

Hi There,

This is a known ** not sure should call it issue, but callback will not work for FileUpload ( e.g. have fileupload in updatepanel )

The trick is assign postbacktrigger to the button that upload the file.

Example:

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<Triggers>

<asp:PostBackTriggerControlID="Button1"/>

</Triggers>

<ContentTemplate>

<asp:FileUploadID="FileUpload1"runat="server"/>

<asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/>

</ContentTemplate>

</asp:UpdatePanel>


Hi,

Thanks for your help, after posting i found other posts on the problem, for future references i add here another help to the problem of the button not sending the file on the first click.

try to use this

in Form tag add this

enctype="multipart/form-data"

example:

<form id="form1" enctype="multipart/form-data" runat="server">

i use that and it works

As inhttp://forums.asp.net/t/1060363.aspx?PageIndex=2


Thank you! I've been fighting with this for a week!
Thanks for the tip!!!!

Wednesday, March 21, 2012

Updatepanel and Literal control

I have a customer search dialog.

The user selects a row from the grid and Literal control is updated with Javascript which should close the dialog should then close and a customer account number field on the parent page should be updated.

This all works until I put the grid inside an Updatepanel - then selecting a row does cause the Literal cojntrol to be updated.

From some testing it seems that the Updatepanel is the cause of the problem - its not letting the grid update the Literal control when it is outside the Updatepanel (And when the Literal control is inside the Updatepanel - updating it doesnt do anything)

I think I can update the Literal control using something like Page.FindControl. However, I have been told that this breaks encapsulation and that I should raise an event from the grid and have the Literal control grab it.

Is raising an event the best solution ?

Updating a Literal with script used to be a great tool for me when I was doing 1.1 development, and posting back all of the time. Setting it with script won't cause the page to execute it unless the page were reloaded.

In this example, you should be fine with removing the UpdatePanel for a dialog box scenario, as a postback will simply cause the dialog window to close.


But I want the UpdatePanel on the dialog box - the user could run a number of searches for a customer before selecting one (Dont think I mentioned that) so I dont want to keep refreshing the whole thing if I can avoid it.
No, you didn't mention that. :)

UpdatePanel and MultiView

I use the new MultiView in a form for making customer reservations. The first panel contains a GridView used to select the customer. The OnSelectedIndexChanged event fills the customer info on the reservation page and then switches to that page of the MultiView. This worked just fine until I added Partial Page Rendering to the GridView using the UpdatePanel. The AJAX is terrific as far as refreshing the grid. I have an alphabet selector at the top of the screen and also a TextBox with associated button to search for specific text. This all works great with AJAX. I only have the grid inside of the UpdatePanel and I have ChildrenAsTriggers set to false. The triggers are specified as the events of the search button and the alphabet selector change event.

Here's the problem. In the AJAX version, when the Select LinkButton on the grid is clicked, the screen stays static - just the first time it's clicked. When clicked the second time, the process continues and functions correctly. If I turn on trace, I can see that the code in the OnSelectedIndexChanged event is executed - up to a point, but then it just stops and the screen remains showing the grid. No error is thrown. I suspect it deals with the MultiView, but I don't understand why it works on the second click.

Environment Notes: EnableEventValidation is set to false in the page declaration. If it is set to true, the the OnSelectedIndexChanged causes an error to be thrown. ChildrenAsTriggers is set to false. I'm using the Beta 2 release and the Nov CTP. I am using a MasterPage, but the ScriptManager is in the content page.

Does anybody have any clues as to this behaviour.

Try to setChildrenAsTriggers="false"and UpdateMode="Conditional"in asp:UpdatePanel.
Maybe debug is the best way to fix the problem.
Try to refer to the?following links?to?debug?client?javascript for reference.
Fiddler http://www.fiddlertool.com

Jasson,

Thanks for your reply. I have tried setting ChildrenAsTriggers to false and UpdateMode has always been conditional. After more research, I am thinking that my issue has to do with a user control (the alphabet selector) that I have on the page. Using trace, just after the call to change the index of the MultiView, the code jumps to the constructor of the user control and then immediately stops running and just shows the original view. I have tried to programatically Dispose of the user control and even got a reference to it and set it to null but I have the same reaction. Ironically, the second time the Select link button is pressed, the process continues correctly.

Here is another strange issue - on a different form. I have a RadioButtonList whose SelectedIndexChanged event is a trigger for an UpdatePanel. If I pre-set the value of the RadioButtonList when I populate it using either SelectedIndex = 0; or by using ButtonList.Items[0].Checked = true; then that specific button of the list does not fire the AutoPostBack when clicked. All the others do. If I don't pre-set any buttons, then they all work fine. The RadioButtonList is not inside the update panel but it is identified as a trigger in the triggers tag of the panel.

I don't think MS AJAX extensions are ready for prime-time yet.

R. Harrold


Yeah, I ran into the RadioButtonList problem and spent ridiculous amount of time to figure it out till I saw your post. I cannot believe AJAX has been shipped with such issue.

I am having a problem with the MultiView inside an UpdatePanel, The multi view has 2 views with buttons on each...

When clicking on the button contained inside the second view (when the 2nd view is active) an error mesage box is displayed (javascript client error) stating that: 'null' is null or not an object. I am not trying to fix the error on the client side (i know what null is and how to validate it). But rather is there a way to fix this on the server side maybe an option used with the UpdatePanel control ?


I think I got the problem, The button on the second view is simply a "continue" button meaning it just forwards client to another page.

Since the error was on the client side, the problem I think was solved by setting:CausesValidation="false" for the button.