How to pass control values from one ascx user-control to another???

Our site is set up using a primary default aspx page that is used as the "base page" for everything. On this page, we dynmaically place various user controls at run-time. This gives us a functionality similar to using frames where the outer-frame actually just sits there while various webfiles are loaded inside of it.

Works great except for one thing...
trying to figure out the best way to pass control names/values accross user controls.
When the same usercontrol is posting back to itself this is a non issue. So far most of our functionality has worked well using the local post-back event of each usercontrol. But that won't suffice for long.
But if I want to hop from one usercontrol to another...since there is no form posting I don't have access to the control names/values from the previous usercontrol.
One solution that was proposed was to read control values from the first user control into a session variables and then read them back from the next usercontrol and then destroy them. Seems like a bit inelagant for something that ought to be more seamless.
One thought is if a given series of related usercontrols are going to be processed in succession...then I could create an outer "shell" user control in which they are placed and this outer usercontrol would be handling the post-back issues and deciding what child usercontrols to remove and add and could pass values between them. Is that more programatically sound? What's the best way to have a parent usercontrol reference controls on its child usercontrols and vice versa? Do I need to expose all the values of the controls on each child usercontrol by setting them up as "properties" so the parent usercontrol can "read" them and gain access? Is there a more direct way?
Thoughts???
Oh brillaint minds out there...what have you done to resolve this issue in your own applications?
0
DaViD
3/11/2004 5:59:27 PM
asp.net.client-side 24353 articles. 0 followers. Follow

6 Replies
493 Views

Similar Articles

[PageSpeed] 27

if you are using vb.net or c#.net make a holdvalues.vb class call funcitons that would save the values to a private varables.  then the next aspx can call functions that retreave them.


I hope that helps
sirfree
0
sirfree1988
3/11/2004 8:25:17 PM
Thanks for the suggestion!

Interesting. How would I pass this vb "holdvalues" object between the two ascx pages? Or would I load it into a session variable?
0
DaViD
3/11/2004 10:30:03 PM
sorry i though it was to user controls on the same page.  yea Session variables would have to do the trick.  somethings i pass from one page to the next via hidden inputs

first page.
response.write("<input type=hidden name=myvar value='heldval' >")
second page
dim myvar
myvar = request.form("myvar")
this will only work with forms and use it only if values that you don't care if someone can see them.
if you don't wish someone to see them then use Session vars
0
sirfree1988
3/12/2004 7:24:53 PM
I improperly mixed terms...

let me rephrase:
How would I pass values between two ascx user-controls that are loaded onto the same aspx page?
Am I really limited to session variables? That's the route I'm planning to take but I was hoping there might be something more direct.
0
DaViD
3/15/2004 1:18:01 PM
No.

You can make Public Properties for that controls like so:
WebUserControl1.ascx.vb

'Local Private variables
Dim mID as Integer
Public Property ID as Integer
Get
Return mID
End Get
Set(ByVal Value As Integer)
'Make any validations such as *number can't be negative or verify it is a number
'then set the value
mID = Value
End Set
End Property

MainPage.aspx.vb

WebUserControl1.ID 'Here is the way you'd access that property now.

0
intrino
3/15/2004 8:20:09 PM
Great. I'm familiar with the get/set properties of custom user controls so that's a great suggestion.

The trick is if these user controls are being loaded/unloaded in succession...I'm assuming that the new user control would need to be instantiated to read the property values from the previous usercontrol...then the previous user control could be cleared (like from a placeholder) and the new one added in its place? Is that the best methodology if just making panels visible/not visible on a single usercontrol is not an option for a given solution?

Thanks for all the help guys.
-dave
0
DaViD
3/16/2004 8:12:37 PM
Reply:

Similar Artilces:

Pass value from one User Control to another User Control
I have tried to pass value from one user control to another user control. Because of Page Auto Postback, Contrls are load before page is loaded. So I get the value in 2nd UC after one more post back operation. I have visited many suggessions but I cant solve this. Is anyone can help me to solve this. Thank U mfhossain@gmail.com Muhmmad Fakhrul HossainEmail: mfhossain@gmail.comPhone: +88 01715 111512Web: http://www.mfhossain.info You'd have to do that through the parent probably in it's Page_Load event handler.   userControl1.publicProperty = userControl2.publicProperty;  ...

want to call one c#.net function in one user control from another user control
hi i have two user controls info.ascx and personal.ascx i have a function like in info.ascx i have a function like showdetails() {   } now i want to access this function from personal.ascx can i do this ? thanks in advance. shwetaThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path  you should better create a class where you will define the "functions" that you need in both files. declare "static" the function and call it like nameofclass.nameoffunction In a web project you can...

How To Pass an ItemId from one ascx control to another ascx control in the same page
Hi All, I am new to Asp 2.0. previously i worked on DotNetNuke. now i shifted to this asp 2.0. and here i am developing a site in that site i am using controls just like modules in the dotnetnuke. so i got one doubt here that is in the dotnetnuke if i want to pass an id from one ascx control to another ascx control there i used EditUrl function so it is very simple. but here there is not such a function for navigation from one ascx control to another ascx control. so can any body help me regarding this.Regards,Ram Mohan Rao Adduri,Techinical Associate,eSymbiosisHyderabad.Mobile: 9490118545...

Updating a Label control in one user control from another user control
Hi all, I have a main page in my music store site that has 5 user controls on it with 1 always showing main content and the others being things like a shopping cart, "best sellers", genre list etc (a la amazon). From the main content control I want to be able to set some label controls in my shopping basket control but I just can't seem to work out the syntax for how to do this: Here's the code I'm using - I'm trying to go to the 4th user control on the page (my shopping basket) then find the appropraite label, cast it locally as a Label then update the value: Label _so...

Pass values from one user control to a user control on a different aspx page
Hello, I have an aspx page titled Search.aspx. Within this page, I have a user control titled Search.ascx. I want a user to input search terms, then on the click of a button, I want to pass the values to another page (SearchResults.aspx)....which will then display the results in a user control. Can someone please give me some suggestions on how to do this? Thanks a lot! Hello, what you can do is: inside ur usercontrol, create a method that returns a dataset or datareader. that is, since u are searching using the usercontrol, then the result of ur search will be return...

Trying to pass values from one control to another control
I have 2 controls on my page. CaseList and Email Reviwer. CaseList contain a datagrid that when the button (5th column) is clicked 2 values should be passed to the email revier control. In the email Reviwer Control I have declared: I have: public void sendCaseIdCatId(int catid,int caseid) { ViewState["EmailReviewerCategoryId"] = catid; ViewState["EmailReviewerCaseid"] = caseid; } in my EmailReviwer control   I tried: //Display the email reviewer panel EmailCaseReviewer.Visible=true; string strcatid = e.Item.Cells[1].Text.ToString(); string strcaseid = e.Item.Cells[0].Text.T...

Setting control values from one user control to another
I have two user controls on a page.  Control 1 is view. Control2 is search.  User selects value on Control2 and I want to update Control1(View).  I cannot find syntax to change values on Control1 from Control2.  The following is function on Control1 that is called from Control2 after pageInit and load on Control1.  I have tried many many ways to findControl but all fail. 'Function on Control1 called from Control2 after Control1 PageInit/load:         Public Function loadForm...

To pass values from one user control to another
Hi,       I have a page where there is a user control. inside that user control(let's say Usercontrol1) i have another user control(lets say Usercontrol2). in the usercontrol2 i have a tree and a button. When the page gets loaded first the treeview in the usercontrol2 should not get populated only when i click on a button in the Usercontrol1, then only the treeview in the Usercontrol2 should get populated. also i want to pass the text of a selected treenode when i click on the usercontrol2's button to a textbox in the userc...

pass value from one user control to another
i have a web page (Page.aspx) that contains a main user control (Main.ascx) which has two other controls within it (A.ascx, B.ascx). I have a text box and a button in A.ascx, when the user clicks the button i want the text in the textbox to be captured and then displayed on B.ascx. I have seen a few discussions on this using RaiseEvent but I'm not sure how to do it. Does anyone have any ideas? check this tutorial in codeproject thanks rasheeda, this post helped me out alot also. http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=115712 ...

How do you pass a value from one user control to another?
There must be an example of this somewhere but if there is I can't find it. I have a web form containing 2 user controls. The first displays a list of people. The user selects the person they are interested in and details of that person are to be displayed in the second user control. What is the best way of passing the selected item from the first user control to the second. I can do it with session variables, but there must be a better way than that. thanks You can use properties for that.User Controlprivate string m_Person;public string Person{    get {...

User Control Passing Data To Another User Control?
I got two user controls in a .aspx page. one user control contains a list of names along with the user id as that listbox .value property. now when the user selects a user a clicks on a command button it needs to send the value of the selected user name to another user control in the same form name shippingInfo; Anyone know how to do this; I keep getting a "Object reference not set to an instance of an object" error message here is the code for the MyContacts control (the one with the user name and user id value) Imports PackageDeliveryVB.ShippingRequestInfo Public Class...

Gettin values from one user control in other user control
Hello,I have a web page in which I have to user controls UC1 and UC2.In UC1 there are few text boxes (eg: txtContactNumber etc...)In UC2 I have a button. On the click of the button I want to get the value entered  in the txtContactNumber textbox which is in UC1 user control.How to do this. Please let me know.Any code for the example if given is appreciated.Thank You.     In the codebehind for UC1 put the following:public string ContactNumber { get { return txtContactNumber.Text; } set { txtContactNumber.Text = value; } }  And in UC2:private string ...

Update one user control from another user control
I have two user controls (.ascx files) on one .aspx page. They are in some kind of master-detail relationship. When I select a row in the GridView in first control, second control is populated with editable data. After changing data and clicking update data IS saved but GridView in first control is not updated.How can I cause that data in first control refreshes, but to keep selected row selected?__Please mark post as answer if it helps, if not come back and ask again! Hi,You need to re-bind the GridView with the updated data source so that it reflects the latest changes. Regarding the cur...

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this?  AllAboutFocus.com. Information Technolo...

Web resources about - How to pass control values from one ascx user-control to another??? - asp.net.client-side

User Account Control - Wikipedia, the free encyclopedia
... Windows 7 and Windows Server 2008 R2 . It aims to improve the security of Microsoft Windows by limiting application software to standard user ...

F8: Mark Zuckerberg Stresses Platform Stability, Users’ Control Of Data, Gap Between Mobile Platforms ...
... address during which he focused on steps being taken to ensure the stability of the Facebook platform for developers , to give users more control ...

Facebook’s latest Android update allows users to control privacy on posted stories
Facebook users have made it clear that they want more control over their privacy. The company’s investors said that repeatedly during Facebook’s ...

Apple invention lets users control time-sensitive notifications with their eyes
... patent published on Tuesday shows continued work into so-called "gaze detection" technology, particularly as a means to control certain user ...

Mac developers: Gatekeeper is a concern, but still gives power users control
... their immediate focus was on the implications of Apple's new Gatekeeper security feature. Gatekeeper allows users to tightly control which ...

Minecraft creator sued over user controls
Minecraft maker Mojang is being sued over the way it gives gamers access to mobile versions of the game.

New digital consent initiative to give users control of personal data
... format, keeping it secure becomes a bigger challenge. One possible solution is User Managed Access (UMA) which gives a web user a unified control ...

SnoopWall gives Android users control over app permissions, ports
New privacy software from a company called SnoopWall gives Android users the granular control over apps permissions that they lost when Google ...

Honeywell Wi-Fi Smart Thermostat with Voice Control User Reviews - CNET
Read and write user reviews for the Honeywell Wi-Fi Smart Thermostat with Voice Control on CNET

Siri speaks louder than Google to most voice-control users
Both Apple and Google's voice-control technologies get high satisfaction ratings from half or more users, but Siri has an adoption edge for many ...

Resources last updated: 1/17/2016 11:26:46 PM