How to call C#.net function in one usercontrol from another user control

hi everybody

i have one function like

bindcs()

{

 

}

in my one user control.

now i want  to call this function from my another user control.

i tried to do this by findcontrol but it get the whole control i dont get it its function.

can anyone help me?

thanks

shweta


Thanks

shweta

In a day when don't come across any problem -you can be sure that you are traveling in wrong path
0
shweta
7/1/2008 12:37:10 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

3 Replies
1532 Views

Similar Articles

[PageSpeed] 52
Get it on Google Play
Get it on Apple App Store

You will need to declare the method as public and then cast the control that you get from FindControl to be the type of the user control.

0
MelvynHarbour
7/1/2008 12:57:41 PM

A good approach for this is to implement an event on the user control that should call another control. Then on the page which contains both controls you subscribe to the event of that control, and when event is triggered you call the method on the other control. Doing it this way will prove more flexible in the future, because you may decide to call more functions from the control (not just one as it is the case at the moment) or you may change the type of the control on which you want to call the function.

On your page you would have code similar to this:

protected void Control1_SomeEvent(object sender, EventArgs e)
{
Control2.SomeFunction();
}

By implementing the functionality in such manner your solution will be much more flexible and you will be able to combine various controls without needing to modify them every time you wish to create different combination of controls.

Hope this helps,
Ivan
0
ivan_osmak
7/1/2008 2:58:20 PM

 Could you explain in more detail how to do this?  Since I am new to Asp.NET, I don't quite understand how to do this.  How do you "subscribe to the event of that control" on the page code-behind?

0
jonnydock
8/28/2008 8:50:18 PM
Reply:

Similar Artilces:

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 call a function from one User Control from another User Control
Hi, I have one User Control in a page, the User Control has a button, when the user clicks on the button, I need to call a function within another User Control (on the same page).  I have made a function public, but I don't know see the function from the other User Control. Can you help me please, Thank you! Aldo have u added a delegate event for the button clicked like in the example below. ////////WebUserControl1 public partial class WebUserControl1 : System.Web.UI.UserControl {public delegate void ButtonClciked(object sender, EventArgs e); public event B...

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

How to call One FORM from Another FORM IN VB.NET
I AM NEW TO VB.NET, I CREATE A REPORT USING REPEATER COMPONENT (FORM NAME IS REP_VIEW) IN ANOTHER FORM (REP_GET) I GET CODE,MONTH AND YEAR FROM THIS FORM (REP_GET) WHEN I RUN THE FORM REP_GET AND GET DETAILS OF CODE,MONTH,YEAR AND I CLICK THE VIEW BUTTON IN REP_GET FORM IMMEDAIATELY FORM_VIEW FORM HASTO BE OPEN AND REPORT  HAS TO BE VIEWED.  BASED ON CODE,MONTH,YEAR SQL QUERIES ARE IN CODE BEHIND OF FORM_VIEW , CONDITIONS ARE CODE,MONTH,YEAR,      WHICH IS GET FROM FORM_GET   PLEASE HELP ME   THANKS  ...

user control calling the function of another user control
I've created two user controls that are being placed on a aspx page: control1 and control2.  I would like to place a button on control1 and when the user clicks the button, I would like to call a function in control2.  How would I do this? TLAlway take some time for fun! Um, if this can be done then you would have to use the qualified name...   Control2.FunctionName(args) Otherwise, you can't do it this way, but you can do it by writing a Class in your App_Code folder and then have Control2 call said Function and then Control1 can as well. If this post hel...

Calling a User Control function from another User Control
I have several User Controls on my main page. They are basically DataLists that are filled contiginent on one another. How do I call a function in one User Control on the page from another one? I would not do that. I would more likely have the page control the interactions with both user controls, surface events on one or both of the controls and have the Page level code handle it. Generally, "Reaching Up" is not a great design. Linking the user controls in the way you are looking to will make them less generally usable, because they will depend upon each other. You could...

User Control calling function in another user control?
Hey there folks, I have a user control (UCInside, e.g.) inside another user control (UCOutside). I want to call a function that's contained in UCInside from UCOutside. Since UCInside has an associated class (let's call it ClassInside), I figured I could call the function by a simple ClassInside.UCInside.MyFunction(params)This calls the function, but I then can't seem to access any of web controls in UCInside from that function. Specifically, I have a RadioButtonList defined in UCInside. I want to retrieve, and then use, the selectedValue in MyFunction. I get an 'object referenc...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

I have a web user control being used by another web user control, but the one being used will not display the labels in the resx file.
I am using DotNetNuke version 3.13 (might be 3.013) on a Window's XP machine, SP2. I have what I find to be an extremely odd situation. I have a project called TDS.Controls. This project is a web control library. Each control has its own resx file, which is located in the App_LocalResources directory. Each control inherits from Framework.UserControlBase, just like DotNetNuke's User control in DNN\Controls\User.ascx.vb. As a matter of fact, this control is doing the exact same thing I am trying to do. It is a web user control with its own resx file being used by another web user control (See ...

How To Convert c#2005.net web template to vb2005.net Forms Template
I need  Convert c#2005.net web template to vb2005.net Forms Template   There are some free c# to vb converters out there which will allow you to upload a project and convert it to vb.   The programming models for windows forms and web projects are very different there is no way to convert a web to windows forms project.   http://www.carlosag.net/Tools/CodeTranslator/Default.aspx      Silverlight-helpVb TipsSpace Coast .Net User Group Hey Ajax-y, This tool really helps all programmers. I thought I would share this wit...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

C#.NET in VS.NET vs. C# in Web Matrix
Hi all, I am very new to .NET ... I realized C#.NET is only available from Visual Studio.NET ... however, I realized Web Matrix also allowed us to choose C# as language but not C#.NET ... they are not the same, right? If not, then why it's in Web Matrix which runs ASP.NET?? If I need to run C#.Net, I MUST GET VS.NET, right? Can C#.NET has the abality to create chat program? Thank you very much. C#.NET and C# are the same thing. JimMS MVP ASP.NET [VC++/MFC emeritus]Old Dog Learns New TricksPreferred programming language: cuneiform on clay tablets So ... that means I can use web matrix t...

How to use a web user control from one web app in another web app?
I have a production web app project (at work) that has custom web user controls in it.I have another web app project for experimenting and I want to use some web controls from the production web app. The big trick is that I need to load the controls dynamically.LoadControl() doesn't seem to work - it complains about loading controls from a different application. I also tried adding a project reference to the production web app and using "UC1 newUC = new UC1();" and then "this.Controls.Add(newUC);", but the controls (like TextBoxes) on the web user control don't seem to exist on the new UC1s....

calling control in one form from another form
hi all, i have two forms in a C#.net windows application i have a list view control in form1. i want to fill this list view from form2 and display form1 from form2. any idea of doing this?thanks in advance use showdialog to get the input.Thank You--some funny homemade software,http://www.geocities.com/lhcsoft2004/my software grouphttp://groups.yahoo.com/group/LauHanChingSoftware/...

Web resources about - How to call C#.net function in one usercontrol from another user control - asp.net.web-forms

'url' Top Users - Stack Overflow
current community chat blog Stack Overflow Meta Stack Overflow Stack Overflow Careers your communities Sign up or log in to customize your list. ...

List of content management frameworks - Wikipedia, the free encyclopedia
.NET Framework , works with SQL Server, VistaDB , with XSLT or .NET UserControls Text is available under the Creative Commons Attribution-ShareAlike ...

OPAC Discovery
Switch Language To switch to a different language, select from the following list: English French Spanish Italian British Bulgarian Galician ...

The royal baby - Australian Women's Weekly
MAKE AWW MY HOMEPAGE SUBSCRIBE AND SAVE TODAY FOOD RECIPES ROYALS CELEBS Home Food Recipe search Recipe collections Meal maker Expert Q & A Cookbooks ...

Envoyer par courriel à un ami - Best Buy Canada
Envoyer par courriel à un ami à Best Buy Canada

Bytes - IT + Developer Community - Connect with IT Pros
Bytes.com is a community for Developers and IT Professionals. Join 414,150 members and discuss topics such as software development, networking, ...

Canonical Splines in WPF and Silverlight
January 22, 2009 New York, N.Y. Windows Forms has two methods named DrawCurve and DrawClosedCurve that draw canonical (aka cardinal) splines. ...

Silverlight Toolkit - Issues
Silverlight Toolkit and Silverlight for Windows Phone Toolkit are a set of Microsoft components for developers.

Delicious
Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

DotNetNuke Modules – Anatomy of the View
-*+Now that we’ve laid the foundation of DotNetNuke modules, it is time to start looking at the specific modules. While it would be practically ...

Resources last updated: 1/7/2016 9:26:45 AM