How to refresh user control in asp.net web forms - asp.net

I have user control having Gridview inside it on parent page,on the same form one popup window gets open for document upload.
When I upload the document from pop window on attach button,it should get reflected to gridview of parent page.
I want to refresh my user control on attach button of pop window.

if you want to refresh your user control to Refresh the data of your grid view, then simply call your grid view bind function here again just after uploading new documents.

Related

how to get or retain file upload control value after postback

hi i have usercontrol on which there is one file upload control, user control is inside Tab container which on aspx page.hirarchy is like bellow:
1.Master Page
2.aspx Page having ajax tab control.
3.User control which is inside tab container.
4.file upload control which is on user control. and submit button
Problem i am facing:
When i click on submit button as page load event is called before buttons on click event value of file upload control is getting nulll.
could you please tell me how can i fetch the file upload control value after postback.
thanks is advance.
The file upload control does not retain the posted file with each request.
When the user selects a file, it will be available in the next PostBack request that occurs.
You should check for a PostedFile on each postback and save this file on the server.
Keep a reference to its path in the ViewState.
Then you can process the file when the user has finished all inputs.

Click event of Link button inside a gridview of user control not working when the control is added dynamically in a web page asp.net?

On clciking a button in the page , I am adding an user control in to a place holder of the page.
The user control has a gridview which has a link button as template field and has a click event associated with it.
When I click the link button inside the gridview , the link button click event is not fired and also the user control disappears in the page.
Please suggest a solution
--You need to recreate all your dynamic controls at the early enough in the page lifecycle (page_load/page_init), so the asp.net will detect events and attach them.
try this knowledge post
http://support.microsoft.com/kb/317794
Why don't events of dynamically added user control fire on postback?
You need to recreate your dynamic controls on every postback - remember a new class instance of your page is created every postback, so any dynamic controls you created the previous time will need to be recreated.
see this article
and this one

Accessing server controls from different pages

I have a GridView on PageA, I wish to be able to call the DataBind() method of the GridView from PageB?
Basically PageB is a form which will be contained in a pop up control, when the user fills in the fields of the form on PageB and submits it I will close the pop up control, then I want to refresh the GridView on the parent page (PageA), how would I go about doing that?
Write a javascript function on Page A like RefreshGrid, you can write various ways to refresh grid from this javascript function e.g.
1) put your grid inside an update panel and create a trigger button control on that update panel , call this trigger control's click event in javascript , this will partial post back the page and refresh the update panel. There are other ways too..
2) From popup on popup close button, write following line
window.opener.RefreshGrid(); window.close();
Thats it.
If you want to pass any parameter you can pass through as argument to RefreshGrid function.
Still there are many ways , this is the one I use.

i want to store value of check box checked in repeater control on page refresh

i have repeater control in my page ,and it contains Questions and its options in check boxes .
i want to store that information if user refresh the page
You can store this info e.g. in cookies with help of a JS handler function of the onclick client events of your checkboxes

Facncybox in Jquery

I am using jquery.fancybox-1.2.1.js of fancy box in asp.net application
Q1: In the base page I have datagrid and on combobox. On selection of combobox, the datagrid is populated.
From the datagrid I open the fancybox when user click on Edit link. I open new page like
In EditProjectTask.aspx I have the controls in edible mode. Now if user closes the window using default icon provided in fancybox, then if user selects some other option from combobox the url changes into EditProjectTask?Task= 86
Q2: #
From the # datagrid I open the fancybox when user clicks on Edit link. I open new page like
In EditProjectTask.aspx I have the controls in edible mode. Now when user updates the the content, I want to close the fancybox and also refresh the parent window.
I have achieved this using
After update i #
But it reloads all the pages. Can I use some Ajax call?
I am not sure about how you would use fancybox for this but here is a great post explaining how you edit your gridview's data using jquery dialog

Resources