I have an Usercontrol on a WebForm, on this Usercontrol is a button, I want
to save data that's residing on the WebForm when user clicks on the button
that's on the UserControl.
How do I call a method that's in the WebForm from the button_click event or
from any other event that originate in the UserControl?
Peter
--
Thanks
------------------- cz****@wsinc.co m 9 1749
Try this...
((URNameSpace.U RWebFormName)th is.Parent).UrFu nction();
Replace URNameSpace with the name space of WebForm
Replace URWebFormName with The web form Name in which control reside.
UrFunction is the Function name
"Peter" <cz****@wsinc.c om> wrote in message
news:un******** ******@TK2MSFTN GP09.phx.gbl... I have an Usercontrol on a WebForm, on this Usercontrol is a button, I
want to save data that's residing on the WebForm when user clicks on the button that's on the UserControl.
How do I call a method that's in the WebForm from the button_click event
or from any other event that originate in the UserControl?
Peter -- Thanks ------------------- cz****@wsinc.co m
Thank you for your help, looks like this what I need and thank very much for
supplying an example!
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:BR******** ******@cpmsftng xa07.phx.gbl... Hi Peter,
Thanks for posting in the community! From your description, you have a ASP.NET UserControl which has a button. When the UserControl be put in a certain ASP.NET page, you want to call a certain method or event handler in the container page from the Button(in the UserControl)'s click event, yes? If there is anything I misunderstood, please feel free to let me know.
As for this question, I think you can try exposing a public eventhandler
in your UserControl and then retrieve the usercontrol in its container page's Page_Load event and set this handler member as one of the Contaner page's handler member function. To make this clearly, I've made a sample page and usercontrol to show the above means and I've attached the source file in this message.
In addtion, I've viewed the web link Avneesh has provided. That also discusses on this means, you may also have a view on it if you feel anything unclear.
Please try out the preceding suggestion. If you have any questions, please feel free to let me know. Regards,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Peter,
Thanks for your followup. I've tested the application you provided and
found that this problem is caused by that you used "OutputCach e" in the
UserControl, so when the page is second time requested, the UserControl is
not in the Page's Controls Collecdtion, it is replaced by a CacheControl.
So the "Null object reference " Exception occured. You may trun on the
page's "Trace" attribute in the <@Page ..> Directive to view the Control
collection or try remove the UserControl's OutputCache directive and see
whether the problem goes away.
Please check out the above result, if you have any further questions,
please feel free to followup.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Thank you very much, removing the OutputCache did the trick! As you can
tell I am very new to ASP.NET and have no clue what each attribute does, or
what to look for when there's problems - so I appreciate all the help!
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:Oa******** ******@cpmsftng xa07.phx.gbl... Hi Peter,
Thanks for your followup. I've tested the application you provided and found that this problem is caused by that you used "OutputCach e" in the UserControl, so when the page is second time requested, the UserControl is not in the Page's Controls Collecdtion, it is replaced by a CacheControl. So the "Null object reference " Exception occured. You may trun on the page's "Trace" attribute in the <@Page ..> Directive to view the Control collection or try remove the UserControl's OutputCache directive and see whether the problem goes away. Please check out the above result, if you have any further questions, please feel free to followup.
Regards,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Peter,
Thanks for your response and your compliment. I'm also very glad that my
suggestions can help you. Also, it's my pleasure to help you. Next time if
you meet any problems or have anything unclear on ASP.NET, please always
feel free to post here. We're always willing to help you.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi,
Peter's problem is caused by the <@output cache > he used on the webform
which will make the UserControl be replaced by a LIteralControl when it is
requested again. If you haven't used any cache on the control, I think you
can refer the following weblinks:
#Web Forms User Controls http://msdn.microsoft.com/library/en...ormsusercontro
ls.asp?frame=tr ue
As for the attached source, I think you need to use OE client to view the
thread. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi,
Peter's problem is caused by the <@output cache > he used on the webform
which will make the UserControl be replaced by a LIteralControl when it is
requested again. If you haven't used any cache on the control, I think you
can refer the following weblinks:
#Web Forms User Controls http://msdn.microsoft.com/library/en...ormsusercontro
ls.asp?frame=tr ue
As for the attached source, I think you need to use OE client to view the
thread. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi,
Peter's problem is caused by the <@output cache > he used on the webform
which will make the UserControl be replaced by a LIteralControl when it is
requested again. If you haven't used any cache on the control, I think you
can refer the following weblinks:
#Web Forms User Controls http://msdn.microsoft.com/library/en...ormsusercontro
ls.asp?frame=tr ue
As for the attached source, I think you need to use OE client to view the
thread. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Curtis Justus |
last post by:
Hi,
I currently have a control that is on a form and I want to pass that
exact instance of the control to another form (a child form that
appears on a button click). The control has state, etc. that works with
both forms.
In my button click on FormA, I take my control and pass it to a constructor
in FormB. Here is the code in the...
|
by: Dave Veeneman |
last post by:
Is there a simple way to pass drag-and-drop events to a child control in a
UserControl?
Here's an example: I have created a UserControl which contains a treeview
and some text boxes. I want to be able to drag-and-drop to the treeview from
outside the UserControl. Now, when I drag over the treeview in the
UserControl, the UserControl gets...
|
by: Stijn Goris |
last post by:
Hi all,
I place a usercontrol (2) on another usercontrol (1). The second usercontrol
has a button. Is there a way usercontrol (1) can know when the button is
clicked on usercontrol (2) without usercontrol (2) having an instance of
usercontrol (1)?
Reagrds
Stijn
|
by: Josh |
last post by:
Hi Guys,
I have been having a big problem with trying to pass parameters into a
user control when the user control is dynamically loaded into a
placholder. I am developing in c#. I have get and set methods on the
user control "editButton.ascx" which work fine.
How do i pass parameter into the user controls "c1", "c2" ?
Here is a bit...
|
by: Dan Nash |
last post by:
Hi
I'm new to C#, moving from ASP, and slightly confused so bear with me!
Basically I've got 4 pages, each of which runs the same user control (some
header information). I want to be able to change the data in the user control
based on the page (everything else would be duplicated, hence the user
control).
Anyway, i thought the easiest...
| |
by: Anonymous |
last post by:
Hello,
I am loading a usercontrol with the LoadControl method
and need to pass some data to the property of that
control. How can I do that?
THanks
|
by: Tarun Mistry |
last post by:
Hi, i have a page with a user control on it, the uc is a form with a submit
button.
On submitting, how do I make the call get picked up by the webform the user
control is in?
Alteratively, is it possible to post to a different .aspx page?
Thanks,
Taz
|
by: Tarun Mistry |
last post by:
Hi all, is it possible to update a usercontrol before it is rendered?
In my scenario I have a Page with a usercontrol on it. When a button is
clicked on the Page, I want to update the usercontrol, more specifically
making a placeholder become visible. However it wont work. Im confused. I
catch the button click even on the page and within...
|
by: Chris |
last post by:
Ok, so I have this sub I wrote, and I create a new instance of a
UserControl:
ctrlAPs tempctrl = new ctrlAPs();
Now, I would like to be able to use this sub I wrote for more than one
UserControl, so I was trying to do something like this:
private void somesub(UserControl sourcectrl)
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |