Solved

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

Posted on 2011-09-08
6
180 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

15 Experts available now in Live!

Get 1:1 Help Now