Showing posts with label outside. Show all posts
Showing posts with label outside. Show all posts

Saturday, March 24, 2012

UpdatePanel and ASP.NET validation controls

Ok, here's the setup:

-- July version of ATLAS

-- Inside an update panel, we have an asp textbox and a required field validator.

-- Outside the update panel we have an image button.

If you click the image button without entering anything in the text box, you get the client-side validation (which is correct). Then, enter valid data and click on the image button with the mouse (don't tab off the text box first). The validator message is cleared, but the the button's click event is never fired. We always have to click it a second time.

We only have this problem in an update panel. Our workaround is to put client-script on the OnMouseDown event of the button to fire the click event. Does anyone know what may be causing this?

Thanks, --David

Turns out it's not an ATLAS problem at all. The validation controls are set to display="dynamic" and they were pushing the image button down (and pulling it back up) and the onmouseup event wasn't completing on the button. Who knew.

UpdatePanel and FileUpload problem.

Hi, all

I got a question.

I have a FileUpload component outside a UpdatePanel Control, and a Button named "Upload" inside a UpdatePanel.

When I clicked Upload, and get the FileName property of FileUpload1, it contains nothing. And the HasFile property is False.

What's wrong with it? And how to handle it?

thanks.

File uploads do not work inside of updatepanels. The button you are clicking is causing a postback, but it has nothing to do with the upload file control textbox and what the path is to the file.

To get ajax style behavior from the file upload consider using the iframe technique.

http://encosia.com/2007/02/23/ajax-file-downloads-and-iframes/

Good Luck,

Louis


FileUpload controls will work with UpdatePanels, but you must set the button as a PostBackTrigger instead of an AsynchPostBackTrigger.

------------------
When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


thanks


I have already tried to set a PostBackTrigger instead of AsyncPostBackTrigger, but it still not work.

<asp:UpdatePanel ID="upFile" runat="server" UpdateMode="Conditional" RenderMode="Inline">
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
<ContentTemplate>
<asp:FileUpload ID="File1" runat="server" Style="display: none" onpropertychange="ctl00_cphMain_txtFile.value = this.value" />
<asp:Button ID="btnUpload" runat="server" Text = "upload" OnClick="btnUpload_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:TextBox ID="txtFile" runat="server" ReadOnly="true" />
<asp:Button ID="btnFile" runat="server" Text="Browse" OnClientClick="javascript:document.getElementById('ctl00_cphMain_File1').click(); return false;" />

ps: I uses a MasterPage, any questions with it?


FileUpload controls is not compatible with UpdatePanel when they are used to upload files as part of an asynchronous postback

See this

http://geekswithblogs.net/rashid/archive/2007/08/01/Create-An-Ajax-Style-File-Upload.aspx


It seems that I can't get FileUpload and UpdatePanel work together..

thanks all

Wednesday, March 21, 2012

UpdatePanel and Outside Controls

if I have controls outside an updatepanel, i then fire an event inside the panel, is it possible to access those external controls from within an event fired from an updatepanel?

thanks.

Hi,

could you provide more details? Are you using a trigger to perform a partial postback? You want to access the external controls on server-side?

I have a dropdownlist placed outside an updatepanel, i have other buttons in an updatepanel, i want when i click on a button inside an update panel to be able to access the value selected in the dropdownlist, having all this done on the server side.

thanks

Updatepanel and ObjectDataSource Bug?

I have an issue with the updatepanel. I have a button outside the updatepanel that is supposed to update the data that the gridview is displaying. I am using the typicalAsyncPostBackTrigger to bind to the button, but for some reason, the data is not being updated. I even have a label inside the updatepanel to make sure the updatepanel is updating, but unfortunatley, the gridview's data stays old until I reload the page or sort the gridview.

Is this an UpdatePanel and ObjectDataSource bug? I've seen a Gridview update, but just not when it comes through objectdatasource. Here is an example of my code.

<

asp:ObjectDataSourceID="objPlanInfo"runat="server"SelectMethod="ViewPlanInfo" TypeName="DataLayer" />

<

asp:UpdatePanelID="pnlPlanGrid"runat="server"UpdateMode="conditional">
<ContentTemplate>
<asp:GridViewID="gridPlanInfo"runat="server"AllowPaging="true"AllowSorting="true"DataSourceID="objPlanInfo"></asp:GridView>
<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label>
</ContentTemplate><Triggers>
<asp:AsyncPostBackTriggerControlID="btnChangeUserPlan"/>
</Triggers>

</

asp:UpdatePanel>

<asp:ButtonID="btnChangeUserPlan"runat="server"Text="Submit"OnClick="btnChangeUserPlan_Click"/>

Nah,

You mist the EventName in your trigger. Add: EventName="Click"

WS


Nah,

You missed the EventName in your trigger. Add: EventName="Click"

WS


I actually had that in before, it didn't work. I tried it again, same problem. Thanks though, any other suggestiosn?
So has anybody been able to get my example working? An update panel that contains a control that pulls data from an objectdatasource with a trigger from a button on the outside??
hello.

well, it should work without any problems. i do have 1 questions though:

1. are you getting a response form the server (use fiddler to check this)
2. are you using master pages? if so, is the button in the master and the updatepanel in a content page? if this is the case, you need to get the uniqueid of the button instead of its id.

Ah friend! You are what they refer to as the "enlightened one". It was indeed a naming error as both my button and update panel were inside a control that inherited from a master page. I feel like I'm closer, but not quite there yet. I don't know how to give the button's clientID on the front end, so I just attached the triggers on the backend on pageload. Here's the code.

if (!Page.IsPostBack){AsyncPostBackTrigger triggerBtn =new AsyncPostBackTrigger();triggerBtn.ControlID = btn.ID;triggerBtn.EventName ="Click";pnlPlanGrid.Triggers.Add(triggerBtn);}

Now oddly enough, I still have the same issue. I tried attaching triggerBtn.ControlID to the btn.ClientID, but it didn't work properly for some strange reason. Am I missing anything else?


Hm, on second thought, that may not have been the issue, because they're both on the same control and you should be binding to the button's id name right?

back to square oneSleep