Solved

ASP.NET / Ajax Problem - calling function in orginal Page

Posted on 2011-09-08
6
179 Views
Last Modified: 2012-05-12
Hi,

Have an aspx pageA which calls via jQuery .load() a different aspx pageB into a div on pageA.

On pageB I have a button control which will cause a postback.  The postback returns pageA which is fine.

However, I need the button control on pageB to call a sub on pageA on postback, but I cannot add the reference of the Function on pageA to the AddHandler of the button on pageB.

Any assistance would be appreciated.

Thanks.
0
Comment
Question by:justinkent
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
drain earned 500 total points
ID: 36504172
Create the button on page A with the correct handler
hide it with CSS.
have the button that you bring in from page B fire that button on A with JS.
0
 

Author Comment

by:justinkent
ID: 36504670
Hi drain,

A damn good idea!

I added the button to pageA, passed it's ClientID through the querystring to the Ajax page, and then got the onclick handler of the button on pageB to click the button on PageA.

However, the response was that the object of the button on PageA was null. In which I guess the JS on pageB can't see it.

0
 

Author Comment

by:justinkent
ID: 36504714
Scrap that - I was assigning the ClientID from the Querystring to a variable AFTER I had assigned the onclick Event Handler!

Cheers - works as I need!
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:justinkent
ID: 36505822
Hi drain,

I know this query is solved, but immediately ran into another issue which is that the PageA can not access the form controls (textbox, listbox) of the PageB page.

Any ideas?

Thanks.
0
 
LVL 4

Expert Comment

by:drain
ID: 36506460
You'll want to look at what kind of html the pageb is putting out.
I assume you want to access the form controls via JS. You won't be able to access them via .NET

But if your form controls on Page B are ASP controls they likely have some things added to the IDs on the page so
<asp:whatever id="blah" runat="server"/>
would become
<whatever id="pageidentifier_blah" />

So your JS has to access the pageidentifier_blah instead of just blah.

Firebug or the like should help you find the correct IDs if you are not sure...
0
 

Author Comment

by:justinkent
ID: 36506585
Thanks drain... very helpful.

:o)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now