Associate
- Joined
- 6 Oct 2008
- Posts
- 41
Hi folks,
I'm having difficulty accessing C# classes from other pages.
To keep this explanation simple, I have a couple of ascx pages which are loaded into an aspx page.
I have created a custom method in the ascx page that will save everything from the page controls into a database table.
ascx page:
aspx page:
But I can't seem to access the method from the ascx page, does anyone know where I am going wrong?
I'm having difficulty accessing C# classes from other pages.
To keep this explanation simple, I have a couple of ascx pages which are loaded into an aspx page.
I have created a custom method in the ascx page that will save everything from the page controls into a database table.
ascx page:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class panels_app1 : System.Web.UI.UserControl
{
public void AppSave()
{
if (Page.IsValid)
{
ApplicantBLL appBLL = new ApplicantBLL();
appBLL.AddApplicant(chkHealth.Checked, chkHelp.Checked, chkTalk.Checked, ddlTitle.SelectedValue,
txtFirstName.Text, txtSurname.Text, ddlGender.SelectedValue, txtAddr1.Text, txtAddr2.Text,
txtAddr3.Text, txtAddr4.Text, txtAddr5.Text, ddlCountry.SelectedValue,
Convert.ToInt32(txtUKYears.Text), txtPostcode.Text, txtTel.Text, txtMobile.Text,
txtEMail.Text, Convert.ToDateTime(txtDOB.Text), Convert.ToInt32(txtAge.Text),
ddlEthnicity.SelectedValue, txtEthnicOther.Text, txtNI.Text, txtULN.Text);
Response.Redirect("http://sqlserv1/misintranet");
}
}
}
aspx page:
Code:
using AjaxControlToolkit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Apply : System.Web.UI.Page
{
protected Control _formApp, _formCourse, _formEducation, _formRefs, _formSubmit;
private void LoadPanels()
{
_formApp = Page.LoadControl("~/panels/app1.ascx");
plhApp.Controls.Add(_formApp);
_formCourse = Page.LoadControl("~/panels/course.ascx");
plhCourse.Controls.Add(_formCourse);
_formEducation = Page.LoadControl("~/panels/education.ascx");
plhEducation.Controls.Add(_formEducation);
_formRefs = Page.LoadControl("~/panels/references.ascx");
plhRefs.Controls.Add(_formRefs);
_formSubmit = Page.LoadControl("~/panels/submit.ascx");
plhSubmit.Controls.Add(_formSubmit);
}
protected void Page_Load(object sender, EventArgs e)
{
LoadPanels();
}
protected void btnSave1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
_formApp.AppSave();
}
}
}
But I can't seem to access the method from the ascx page, does anyone know where I am going wrong?