Web Forms :: Pass Data From User Controls To Their Parent Forms?
Jun 10, 2010
I'm building a web page that is going to make extensive use of User Controls. Using "LoadControl" it will have one of about 20 different User Controls loaded at any one time. Each User Control is somewhat different, gathering different sorts of data.
I've already built the mechanism to load the User Control and pass strongly typed data to it. But now I'm tackling the part of returning the user data to the Parent Form. I can think of several possible approaches to take but wanted to reach out to the community to learn what the best practice for doing this is.
i want to pass the value of variable form popup page to main page. i have try to use the session but i can't because the main page is start before the popup page start.
Within the EditItemTemplate and InsertItemTemplate I have a cell that has a textbox and a button.
When the button is clicked a popup window is shown, where the user can upload a picture. The name of the uploaded picture is retrieved.
Now I want to send that picture name back to the textbox within the listviews EditItemTemplate or/and InsertItemTemplate (that is ofcourse one at a time depending on what the user is doing, inserting or editing a row).
The code I have written so far looks like this. The below code has been abbreviated
[Code]....
The code behind looks like this (also abbreviated). Actually I don't think the code behind is needed, since its mainly javascript from the popup window (child page), but nevertheless here it goes.
[Code]....
And at last the child page / popup page.
Well there is not anything to see here, cause I'm using the Telerik RAD upload control, which is doing everything for me.
However the line below may be of interest. Here I'm taking the name of the uploaded file (picture) and printing it to a label.
I have one parent gridview where each record will link to its details page (another child gridview in modal popup). May I know how do I store the values of the child gridview temporary (maybe in session) and repopulate the data into the parent gridview? Current problem is: once I click save in the child modalpop gridview, it binds the parent gridview before the child gridview data is stored in session. I want to store the data temporary until user click save in the parent gridview.
I have a user controlThe user selects some items from user control (check box list)User clicks update button on user control The new rows get updated on a gridview on calling page & user control is hidden
a)I have made the user control but I dont know how to return the results and bind them with gridview on my calling page.
b) Update: If I create the update button outside the user control and on my calling page and then on its button click event Isomehow access user control checkbox list selected items would that be a good approach ? And how to do this stuff ?
This is placed in the sqldatasource selecting sub. It works well and loads up data from the database based on the @UserId parameter.
I load up the detailsview and it only loads up data from the DB based on the currently logged in user, however i want them to be able to insert some data too.
Anyone know how i can achieve this when they select insert? For starters i having endless parameter problems but i am sure i can sort that out. what i really need is someone to tell me how i can pass the UserId into the USERID text when the details view mode changes to "insert"
I know there is a "mode changed" event, should i be using that?
I'm developing an ASP.NET application with C# and Ajax.I have a page that holds user controls loaded dynamically. I need to pass some data (integer values and some strings) to the user control that has been loaded dynamically.Now I use Session to pass these values, but I think I can use another way; something like VIEWSTATE or hidden input.What do you recommend me?The fact that I load the controls dynamically is important because controls are loaded on every postback, and I can't store any value on controls.
I have a page, let's called that Parameter page, displaying data from a database table using GridView. (The database is a SQL database.) I allow editing of data in GridView. The GridView uses stored procedure to retrieve data and to update data. In my project, users need to log in before using my asp.net project. So at every page, I know who the current user is by using HttpContext.Current.User.Identity.Name. Now as requirement changes, I need to record who has changed what (row) in the Parameter page. The information is to be written to a new table - audit log. Therefore I do not expect to change the Parameter table structure.
I have modified the stored procedure retrieving data. It returns one more column - an empty column with name currentUser. So GridView will create one more column. After data bound, I have the GridView_DataBound() to popluate that column using HttpContext.Current.User.Identity.Name.
I debug it in Visual Studio and am able to see the name of current log in user as the last column in GridView. I change the update stored procedure to take in one more parameter. That parameter, currentUser, takes default value. The default value is an empty string. So if UI part fails to send in the current user name to stored procedure, it just write the empty string as the user name. I change the <asp:SqlDataSource>. I add a <asp:Parameter> for currentUser.
[Code]....
I debug in Visual Studio. However when I save the change, the SQL profiler shows UI sends in @currentUser as NULL. Why?
I am trying to write a simple application that will allow a user to pass a value from the parent page to a textbox in an IFrame.
Parent Page will only contain 3 controls (label, textbox, and a button). Once a user fills in the txtbox and then clicks the button I want the value that was put in the textbox to be sent to a textbox within an IFrame.
IFrame will contain a label, a textbox, and a button. Once the value is passed from the parent's textbox control to the iframe I want to also fire a button event in the iframe that will simply be:
[code]...
I am not worried about passing the value back to the parent page. My goal here is to create a testing application for my website. I want to automatically populate textbox's / radio buttons / date time pickers within an IFrame from a parent webpage. I am determining the stress on the server and testing the functional aspect of the iframe's website.
I am working on user controll.My user controll is loaded in .aspx page and that .aspx page is opened as Pop up window.I want to Pass control back to Parent page when i click on save button of user control which is in pop up window.
I have an asp.net page which launches a child page in another browser window to look like a popup. I want to pass 2 pieces of data to it from the parent page. I know ots possible with javascript, but is there a way to do it using C#?
I am using an IFrame in one of my aspx pages. The source for the Iframe is an aspx page which consists of several links of other pages(All are developed in .net 2003) now i am using 2008.The Problem is for some of the pages there is query string which consists of username.I need to pass the username from the parent page to the IFrame pages.Is there any way to acheive this?
I have a user control that has several data components
What I want to do is populate the data components based on the parent's page title where the user control is called.
The parent page title is the most logical unique name to each page and so that would be the name that I want to import
as the default value for the data components select parameter. Each page name is stored in my sql data table [Towns] as TownsName.
The general idea is that the control will populate with the towns data based on the page title of the parent page.
<SelectParameters> <asp:ControlParameter ControlID="DetailsView3" DefaultValue="PAGE TITLE NAME GOES HERE" Name="TownsName" PropertyName="SelectedValue" Type="String" /> </SelectParameters>
I am not sure how to code this correctly, but I am sure it would have to be called in the page load statement.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load SetAttr(DetailsView3.DefaultValue = Parent.Page.Title())<-------THIS OFCOURSE DOES NOT WORK End Sub
I have spent a couple of days trying to work this one out and have failed to find a workable solution..
I've to Web User Control. I want my first usercontrol redirects the page to the page which second userscontrol is in. I think this is not a good idea to put the address of second page in the user control. what's the best idea to acquire address of the page of second usercontrol?
I have 2 user controls that is hosted by 2 different aspx pages.
example:
srcpage.aspx --> hosts the --> sourceusercontrol.ascx and destpage.aspx --> hosts the --> destinationusercontrol.ascx
I would like the values in the text fields of the sourceusercontrol.ascx to be passed on to the labels in the destinationusercontrol.ascx.
I have gone through the MSDN ASP.Net examples and i was able to successfully pass values between two aspx page using the postback URL functionality, but cannot do the same thing with the usercontrols on 2 different aspx pages.
I have a page (parent) that open up a popup window using window.open javascript. User will then work on the popup window and the result will be stored in a session variable. When the user close the popup window, how can I put the value of the session variable back to the server control textbox of the parent window?
I have this weird problem. I have an aspx page which contains a User Control(Parent). This Parent User Control contains another User Control(Child). Now, when i run my website it works ok until I have make some event inside the child control, at this moment the parent control stop responding!!!. The child user control appears and loads data correctly but when I try to do something inside it, the parent user control stop working correctly.
I have to develope on popup page which is popout from parent page,popup page have one grid with radio button,according to selection of particular radio button of gridview row and user click on select button popup should close and on parent page we have ID value of selected row of popup page.
According that ID value i have to fill some details in Parent page.
Popup Name Email RBT ABC A@yahoo.com RBT DEF B@yahoo.com
SELECT BUTTON
So my query is how to close popup on select button and pass checked row id value to parent page and on parent page how can we get that id value and display some details.
I'm having trouble to access a Parent's property in User Control. I don't know how to access the parent. The Parent Page's name is Search.aspx. I saw the example below and tried it:
[Code]....
Than I could access the Parent's Property, but when I ran the website I got these errors:
1. The user control is not declared in the parent page 2. The user contol has a circular reference
Basically, I have a user control with a set of input controls such as textboxes and radio buttons. It also has a button along with these controls. What I want is that when the user clicks this particular button, the data entered in the input fields must get updated into a grid in the parent page.