H.Ghassami
H.Ghassami

Reputation: 1022

ASP.Net : How to call a method from one web page with another web page

I have a web site that includes two pages. one of them shows my basket (basket.aspx) and the other shows the product(product.aspx). I want to update grid view in basket page when the users click on each products when they buy them.
I test this solution but this code doesn't work for me.

ASP.codebehind_files_default2_aspx page = new ASP.codebehind_files_default2_aspx();

after ASP. a message VS just show the name of my page and global.asax.I was searching in Google and the other codes just say the name of the page and define a variable to calls its method, but in my website i can't do that.

So How can i do that? :(

Upvotes: 0

Views: 1003

Answers (2)

peroija
peroija

Reputation: 1982

if you make the basket a user control it will become easier to handle than an iframe (which, without going into great detail is rather frowned upon). You can put the user control on the master page and you will be able to access the user control's methods (think add/remove item). As Pleun mentions, the basket data should be stored somewhere else and the basket user control will just be displaying that data.

Here is some information on user controls:

  1. User control shopping cart
  2. Accessing a user control in a master page
  3. Overview of user controls

Upvotes: 1

Pleun
Pleun

Reputation: 8920

Probably it is a better idea to have the content of the basket stored somewhere else (Database, Session, file ).

Let's assume it s a database table.

  • Make the Basket.aspx simply show all what is in the basket table from it's own codebehind.
  • Make the Project.asxp insert the product to the basket table.

This way your presentation is more separated from your business logic

Upvotes: 2

Related Questions