ASP.net adding multiple triggers for update panel - c#

I have got an update panel in my master page.
in my child page i am trying to upload a file using fileupload control.
page is submitted using a link button called lnkSaveRequest. upon submission page throws a lnkComplete pop up button and think that is preventing my file from being uploaded.
when I try to add both lnkSaveRequest and lnkComplete in triggers
UpdatePanel updatePanel = Page.Master.FindControl("up") as UpdatePanel;
UpdatePanelControlTrigger trigger = new PostBackTrigger();
trigger.ControlID = lnkSaveRequest.UniqueID;
trigger.ControlID = lnkComplete.UniqueID;
updatePanel.Triggers.Add(trigger);
I get the following error
Control with ID 'lnkComplete' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement
either INamingContainer, IPostBackDataHandler, or
IPostBackEventHandler
if I remove the lnkComplete from trigger code , I don't get any error but the file doesnt get uploaded.
Any help much appreciated. or if anyone knows other ways of dealign with update panels in master page please help.

Check remark section in those links, read carefully.
http://msdn.microsoft.com/es-es/library/system.web.ui.postbacktrigger.postbacktrigger(v=vs.110).aspx
'Use the RegisterPostBackControl method of the ScriptManager control to programmatically register a postback control.
http://msdn.microsoft.com/es-es/library/system.web.ui.postbacktrigger%28v=vs.110%29.aspx
Sample postback trigger:
http://msdn.microsoft.com/es-es/library/system.web.ui.postbacktrigger%28v=vs.110%29.aspx

Related

Multiple update Panel in Form

I am new Asp.net and working on project, where I have to ajaxify the basic asp.net
I have master page and content page. Master page has menu and buttons. The content page have various fieldsets as below.
Update Record Fieldset
Add Record Fieldset
Query and Grid.
updatepanel id=UpdatePanelOuter runat=server UpdateMode=Conditional> Likewise for all the nested UpdatePanels. The Scriptmanager is in Masterpage with EnablePartialRendering=true
What I have in code behind is ScriptManager1.RegisterAsyncPostBackControl(AddUpdatePanel) In button click event function AddUpdatePanel.Update() .
When the content page is loaded, I have the queryform and DataGrid. There are couple grid command like view, update and delete.
When I click update command from the grid, I am making UpdateFieldset.visible=true and QueryGridField.visible=false.
On submit button, its stored the data , give the message and go back to original contentpage with querygridFieldset.visible =true.
Question: What I am trying and have not been successfull is
when I click on the buttons, my datetime , menus in the master page
must not be refreshed.
On click in the Update button, only that particular Fieldset should
be sent to the server.
At the same time, I have updated by Web.config and there is no compilation error
Master Page: Menu, Current System Date time, Login Name, Buttons
Content Page: ContentPlaceHolder1 UpdateRecordFieldset AddRecordFieldset QueryandGridFieldset
Not sure what excalty is your requirement but if you have multiple update panels and master page and content page structure.
Please check the script manager and update panel properties according to this link:
http://www.asp.net/ajax/documentation/live/overview/updatepaneloverview.aspx
"Using UpdatePanel Controls in Master Pages" & "Using Nested UpdatePanel Controls" are titles in same link.
Hope this help.

Reload a Web Page Using C#

I have a web page that prompts for user input via DropDownLists in some table cells. When a selection is made the selection replaces the DropDownList so that the action can only be performed once. In the case that a change needs to be made I want to be able to click a button that reloads the page from scratch. I have Googled and Googled but I have not managed to find a way to do this.
Any advice is appreciated.
Regards.
Put a link on the page with the text "Reload" and the url the url of the page. It's perfectly valid to have a page with a link to itself.
If you don't like the link idea, use a standard Button and in the click event, use Response.Redirect to redirect to the current page.
You can set an OnClick for your button that resets each DropDownList's SelectedIndex to 0 instead of reloading the page from scratch. Alternatively, you can set a Response.Redirect([the page's url]) into the OnClick as is suggested here.

AsyncFileUpload, can't refresh page after upload is completed

I have an Ajax AsyncFileUpload on one of my pages (inside a update panel). The control works, however I want the page to reload after the upload is complete. I tried a Response.Redirect in the code behind for the OnUploadedComplete method and a location.reload(true) in the OnClientUploadComplete. Both result in javascript alert of `Server Response Error: 'Unknown Server error'
Do you want to see the response page?` and the page doesn't refresh.
Has anyone been able to do a full page refresh after the upload has completed?
Edit: I mistakenly said the AsyncFileUpload is in a control panel, I meant to say update panel.
Use asp:FileUpload control and register it as postback control with Scriptmanager's RegisterPostBackControl method. Or add postback trigger entry for this FileUpload to Triggers collection of UpdatePanel
This control panel that you told. Is this a UpdatePanel? If it is, you can try an upd.Update(); to refresh the panel.
Becareful, if you have Response on your backside you may be ending your page's life cycle right there. This is just a guess. Check to make sure that your code is even reaching the intended point. Look for things like Response.End which will will prevent anything thereafter from executing.

how to reload the usercontrol in the master page with effecting other part of the master page

I have a master page. In that master page i have a user control which holds a Label control, it shows data read from a text file using marquee.
My text file changes every 2 minutes so I want to reload my user control every 2 minutes without effecting the master page.
How can i do that?
Any help is appreciated.
You could put the user control in an UpdatePanel and refresh the contents via an AsyncPostBack trigger as described in the following article:
http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers
Here is one sluggish solution:
put the label control in a new page (with no master page) and add a timer with that label to refresh every 1 minute or so.
Now, go back to your master page and add an iframe with SRC pointing to the new page you created before. This way, all the refresh effect will be limited to the iframe only and not to your master page.
*Edit: you don't need a timer for the page inside the iframe. Just set the META refresh time period to whatever you want and in the code behind of that page, let the Page_Load event populate the label
UpdatePanel and use a Timer.
http://msdn.microsoft.com/en-us/library/cc295400.aspx

Details grid view refreshes the whole page unexpectedly

I have a grid view and details view. My details view is in the update panel and it should be displayed for edits of the gridview. I have a file Upload control inside detailsview, Now when I click the upload button the whole page gets refreshed.
What do I do and where do I do? I think it should be some problem with the postback triggers.
use this..
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx
set
<Triggers><asp:PostBackTrigger ControlID="your fileupload control id" />
</Triggers>
in update panel
I think , you must post back when uploading a file, but try to do the following:
in the file uploader event : call the following method:
updatepanelName.Update();
If, it should not get refreshed then use the AutoPostBack= false in Upload control.

Categories

Resources