Call codebehind method from aspx page OR call javascript function of usercontrol control from page

Hi,

I have a page which contains a user control.  When a user clicks on a submit button, I'd like to detect when elements in the user control have changed and popup a message box if changes have been detected to confirm if the user wants to save the changes.

Obviously the message box is executed using javascript.  But I'd really like to be able to call a method in the code behind of the page which queries the user control if it has changed.  Is there a way of calling the code behind method from within a javascript function?

Otherwise, if I make all the functions execute on the client using javascript, if I have a function called "ConfirmUserControlHasChanged()" on the page, which pops up a message box if the user control has changed, and a function called HasChanged() in the user control, what would I write in the "ConfirmUserControlHasChanged()" to call the user control "HasChanged()" function?  Can this be done?

0
jesibl
2/28/2007 12:34:24 AM
asp.net.client-side 24353 articles. 2 followers. Follow

2 Replies
1708 Views

Similar Articles

[PageSpeed] 29

Well, you have several options.

[WebMethod] attribute if you google, will bring up some ideas.

Another is to go the ajax.net route, and you can simply use update panels.

Another, is in your javascript submit button, call your own xmlhttp object and do a get for a webservice, and pass in any params from the user control you want.

THe most straight forward is with Ajax.net probably, as you can just use standard asp.net controls, and most of the time they will "just work" with callbacks instead of postbacks.

If you have alot going on on a page, than ajax.net updatepanels may not be the most "performant" and you might want the more complicated custom js and web services.

 


Jonathan Minond
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
0
jminond
2/28/2007 2:02:15 AM

Well, you have several options.

[WebMethod] attribute if you google, will bring up some ideas.

Another is to go the ajax.net route, and you can simply use update panels.

Another, is in your javascript submit button, call your own xmlhttp object and do a get for a webservice, and pass in any params from the user control you want.

THe most straight forward is with Ajax.net probably, as you can just use standard asp.net controls, and most of the time they will "just work" with callbacks instead of postbacks.

If you have alot going on on a page, than ajax.net updatepanels may not be the most "performant" and you might want the more complicated custom js and web services.


Jonathan Minond
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
0
jminond
2/28/2007 2:04:38 AM
Reply:

Similar Artilces:

Calling a method from a control page on the axpx page where the control page exists.
Hello,  I have an .aspx page that has a method called grdMain_DataBind().  I have a control page that loads within the aspx page which has its own logic.  I have a button on my control page called "SAVE".  How can I call the method grdMain_DataBind thats in my aspx logic from the control that exists on that page when I click SAVE button.  Is there a way? If I were you, I'd simply create a "Save" Event within your control. When the Button in your control is pressed, in the Click handler for that Button you can raise the event. Then, within t...

Call public method on aspx page from a web control embedded in the page
I have a nut to crack. How do I call a public method on my aspx page from my web control, the web control is embedded into the page. The markup looks like this:-   1 <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 2 <ContentTemplate> 3 <asp:Xml ID="Xml1" runat="server"></asp:Xml> 4 <uc2:tier3menu ID="menu1" runat="server" /> 5 </ContentTemplate> 6 </asp:UpdatePanel> I wrote an itemcommand thingie in the web control that needs to set the Documentsource a...

Call Server Side method from JavaScript function in Master Page
 I have a JavaScript function in a Master Page. The function is below. function Add(q, p) { //call server side method }  I want to be able from within the JavaScript Add function defined above, call a C# server side method and pass the values q and p to it. No value is returned.I have tried PageMethods.CallServerSideMethod(q, p); but it will only work in a Page, not a master page.Is there any way I can do this in a master page?  How about using a web service call?Encosia - ASP.NET, AJAX, and more.Latest article: Using complex types to make calli...

Custom Control: Calling a function on calling page FROM a custom control ? help !!
I have a custom control placed on many pages, to make things simple, basically what I want to do is Call a function on the calling page from the custom control ieAnyone have any ideas, simple solution would be good !!  This is the code I have myControl.ascx.vbPublic Partial Class myControl    Inherits System.Web.UI.UserControl    Protected Sub testButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testButton.Click        'call save function on PersonalDetails.aspx.vb  &...

Call a javascript function from a report, the function is in aspx page
Hi    How can I go about calling a javascript from from a report. The function is in teh code behind aspx page. When a user clicks a link on the report, this function needs to be called. Further, the report sits in an iframe of the aspx page. So somehow I need access to the aspx page without opening any other pages. I tried using this ="javascript:void SelectTab('tabScoreCard',EnergyExpert_" + Fields!EnergyExpertKey.Value.ToString() + "')"  but that gives me an error of no object found, when the user hits the link on the report to go back t...

Calling a function on a page from a control that is contained on the page
I have a page that contains several Web User Controls. Is it possible to call a function/subroutine on the page from inside one of the user controls? TIA,Owen yes you follow the following: 1- add new class call it BasePage which inhirits from System.Web.UI.Page. 2- let the code behind class for the page  that will hold the control inhirits from this BasePage Class. 3-add the function you need to call in the BasePage Class. 4- in the control in the button click event for an example, you will use the following code to get the page which contains this control, cast it to t...

call method from aspx Page into ascx Page
Hi,I am having following code on Default.aspx which contains my User Control MenuTabs.ascxpublic void Test(){    //my working code} *******************************************************************************************************  My User Control Page MenuTabs.ascxprotected void imgmyrb_Click(object sender, ImageClickEventArgs e){       Here i want to call Test() method which is available in the Default.aspx }    protected void imgmyskills_Click(object sender, ImageClickEventArgs e){       H...

Setting width for .net controls in code(.aspx) page using function call in code behind..
Hi,  Currently I am trying to set the width of the asp.net Table as follows. <asp:Table width="<%=GetWidth()%>" >   and code behind protected Unit GetWidth() { return Unit.Percentage(50); }     It's not working. I know that it works if I set the width complete on some page event(like page_load) of code behind....   Is there a way to maintain the same syntax like calling code behind function in design page...i.e. calling function of .aspx.cs in .aspx page and assign the width as shown above.   Thanks and regards, Giridhar...

Calling a server side method from javascript without page methods
Hi everyone.  I'm trying to do some like this:  if (confirm("foo") == true) {    MyServerSideFunction(); } Of course, I can call this function using PageMethods, but since this function in my code behind shold be static, I cannot call others methods inside my class. Is there any way to call serer side methods without using PageMethods?   Thanks, and sorry for my bad english! You can use ajax to call a webservice from javascript. Check out this article on how to do it: http://www.semenoff.dk/en/Code-Corner/ASP.Net.AJAX/WebService-From-...

Call server-side page function from client-side button click
I have an existing ASP application that I am migrating to ASP.net. In the ASP app I was using the Microsoft.XMLHTTP on a the client-side of a ASP page to retrieve data from another asp page using the Microsoft.XMLDOM object. The client page passes 3 tags columns, table and Criteria. The receiving page builds the SQL statement executes the query and returns the row with all the column data. I am trying to convert it over to ASP.NET and I am getting errors on the xmlDOM.Load(Request.InputStream) on DLookup.aspx, the code is listed below. Someone suggested to use System.Net HTTP classes su...

Can I call a method on aspx page thru the method of control(ascx)
Can I call a method on aspx page thru the method of control(ascx)Ajay Pathak MVP All About ASP.net better u can createa method in class and access from ascxHAPPY CODINGhttp://shobhitrai.blogspot.com/ Your question is not clear to me, You mean to call method which is in aspx form ascx??Imran[MCTS]Few have audacity to speak truthhttp://knowledgebaseworld.blogspot.com/ Hi, Please refer the following code,  uc.ascx:<%@ Control Language="C#" ClassName="uc" %> <script runat="server"> protected void Page_Load(object sender, EventAr...

Calling a method written in .cs page from aspx page
Can we able to call a method coded in aspx.cs page from an asp control?This way:eg.aspx page----------<asp:TextBox ID="txtbox1" runat="server" OnTextChanged=<b>GetText()</b>></asp:TextBox>aspx.cs page------------public void GetText(){} Yes.  But the easiest way to set this up to ensure it works is to double-click the text box in Design View.  That will automatically add the OnTextChanged event handler to the text box, and create the beginnings of the method for your code:<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="...

How to call a javascript fn on page load of aspx page
hi ,   i m new to dot net can any one post the code tocall a javascript fn on page load of aspx  page You would do it in the same way as any other type of web page:<body onLoad="myfunction();">  Regards Mike [MVP - ASP/ASP.NET]My site in ur page load btnSumbit.Attributes.Add("onClick","Functionname(Param1,Param2.......)") hope this helps  Saima Ghumman--Mark the post as Answer if the Post helps you-- Sam.Dev:in ur page load btnSumbit.Attributes.Add("onClick","Functionname(Param1,Param2.......)")&nb...

Calling a javascript function in the content page from the master page.
I have an <asp:Menu on a master page and for one of the menuItems navigation url I can use 'javascript:myfunction()' to call a javascript function in the master page. No problem. Now, what I need to do is use that same master page <asp:menu menuItem to call a javascript function in the content page. Does anyone know how I can call a javascript function located in the content page from the master page using an <asp:Menu menuItem navigation url located on the master page? Thanks,   Steve HI On the content page load u need to find the master page ...

Web resources about - Call codebehind method from aspx page OR call javascript function of usercontrol control from page - asp.net.client-side

'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/21/2016 2:37:24 AM