CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 3/22/2005 5:56:15 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 335 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
ning.ho
Asp.Net User
how to call aspx's function within ascx code?3/22/2005 5:56:15 PM

0

Hi ,

I wrote a user control mycontrol.ascx,
there is a button-A in mycontrol.ascx,

then I use mycontrol.ascx in main.aspx,
the main.aspx have a TextBox-T and a public function-F,

now, when I click buton-A in mycontrol.ascx,
how can I change the TextBox-T.Text on Main.aspx,
and how can I call the function-F on Main.aspx?

--Ben
miguelcastro67
Asp.Net User
Re: how to call aspx's function within ascx code?3/23/2005 2:29:16 PM

0

This is easier than you think.

create an event in the code-behind of your ASCX.

public event EventHandler ButtonClick;

then trap the click event of your button within the ASCX itself and raise your custom event.

protected void ButtonA_Click(object sender, EventArgs)
{
if(ButtonClick != null)
ButtonClick(this, new EventArgs);
}

Next, on your ASPX page, make sure you've declared the ASCX in the code-behind. Unfortunately this is not like WebControls where the declaration is automatically inserted for you. Remember this is done at the class level.

protected MyControl ucMyControl; // assuming you named it "ucMyControl"
In VB:

Protected WithEvents ucMyControl As MyControl

You then have to wire your event (you can do it in the Page_Load):

ucMyControl.ButtonClick += new EventHandler(ucMyControl_ButtonClick);
In VB:
AddHandler ucMyControl.ButtonClick, AddressOf ucMyControl_ButtonClick

Then finally, create the method:

protected void ucMyControl_ButtonClick(object sender, EventArgs e)
{
// This is where you can make whatever changes you want to your page.
}

I hope this helps - good luck.

Miguel Castro
www.dotnetdude.com
ning.ho
Asp.Net User
Re: how to call aspx's function within ascx code?3/24/2005 4:43:38 PM

0

Thanks Castro,

My test is ok now,

Thanks a lot.
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 1.0 with Visual Basic.NET Authors: Chris Goode, Rob Birdwell, John Kauffman, Christopher L. Miller, Neil Raybould, Ollie Cornes, S. Srinivasa Sivakumar, Matt Butler, Dave Sussman, Gary Johnson, Chris Ullman, Ajoy Krishnamoorthy, Juan T. Llibre, Pages: 816, Published: 2002
ASP.NET in a nutshell Authors: G. Andrew Duthie, Matthew MacDonald, Pages: 979, Published: 2003
Building an ASP.NET intranet Authors: Kourosh Ardestani, Brian Boyce, Jonathon Walsh, et al., Andy Elmhorst, Matt Gibbs, Pages: 480, Published: 2003
ASP.NET website programming: problem, design, solution Authors: Marco Bellinaso, Kevin Hoffman, Pages: 576, Published: 2003

Web:
HiveMinds :: View topic - use ascx function in aspx page If you're using code-behind, I'd choose this approach (are you using ... Typically in the ASCX you'd define event handlers, and then call ... The only interface into the ASCX the ASPX would have is through those events. ...
Page-level caching, or passing data between different ascx:s NET I (in my aspx-file) instantiated a class called CurrentState which I then passed on to ... Lets look at some code, I still use a CurrentState class but never instatiates it and ... My ascx-files, when they need the list of messages, they just call ... regardless of how many ascx-files calling this function. ...
CodeProject: Remote Scripting. Free source code and programming help The callback function (which is not a string parameter) is also optional and if ... If you care about the RemoteMethod 's result, add a callback method to get it .... I have it working within a regular ASPX page, but I'd like to be able to call a ... Re: Call to ASCX code behind, member, Michael10, 3:11 24 Jan '05 ...
How to: Customize the Variation Root Landing Logic ... and its user control from within VariationRootPageLayout.aspx. ... //If nothing is done here, then this function returns null //and the landing behavior ... A note on copying the .ascx code to the VariationRootPageLayout.aspx page ... Update the VariationRootPageLayout.aspx for whatever site collection(s) need ...
Saving RadEditor "Prometheus" content directly in the ASPX or ASCX ... Feb 24, 2009 ... The code example below demonstrates how to save content directly in ... //call this function and pass a reference to the RadEditor control ... )[\\s\\ S]*?", mEvaluator, RegexOptions. ... //"Another process or user is using the resource (ascx/aspx file) you are trying to update." ...

how to call aspx's function within ascx code? - ng.asp-net-forum ... how to call aspx's function within ascx code?, > ROOT > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum, Date: 3/22/2005 ...






do i have to register my dll before use in a vwd web app? (unable to load dll 'scansw.dll': the specified module could not be found. (exception from hresult: 0x8007007e) error)

how to replace string starting with "<!-- start here" and ending with "end here-->" with another string?

possible to break a very long line?

problems with response.redirect

need help for some beginner coding

asp.net posting issues

where do you get the value for the membershipprovider type?

preselecting multiple values in a listbox from a dtrreader

add windows account to webserver

stuck on if then statement with control

converting a aspx page to a pdf

i need help aligning text boxes

tables, rows and columns....questions....

urgent require

how to create charts in vstudio

how can i show data

hide table row

possible to use dynamically 'named' type in ctype statement?

refering the .net 2.0 assembly in .net 1.1 framework

microsoft.data.sqlxml name space

inserting a variable into an aspx page

image upload / auto resizing help

install express alongside sql 2005?

error - "'control' is not a member of 'form'."

split function

how can i check a type of generic parameter?

context accessible in classes in app_code dir

hiding .flv's

how- from string to object name

get command name

   
  Privacy | Contact Us
All Times Are GMT