I have a usercontroller (GeneralSetting.ascx) which is inside Setting.aspx. Like this i have 10+ usercontrollers inside Setting page. My requirement is to save values of usercontroller into db and i need to use only .ascx & .ascx.cs files. Is it possibe to do as such.
Please find below the code snippet.
GeneralSettings.ascx=======
function SaveGeneralSettings() {
debugger;
if (ValidateGeneralSettings()) {
var txtSamplingPercentage = $("#txtSamplingPercentage")[0].value;
var txtAttempts = $("#txtAttempts")[0].value;
var txtTimeInterval = $("#txtTimeInterval")[0].value;
TicketSampling = new Object();
TicketSampling.SamplingPercentage = txtSamplingPercentage;
UndeliveredMail.MailRetryCount = txtAttempts;
UndeliveredMail.RetryTimeInterval = txtTimeInterval;
PageMethods.UpdateGeneralSettings(TicketSampling);
}
return false;
}
GeneralSetting.ascx.cs=======>
public partial class Settings : PageBase
{
#region properties/variable
private const string TABRESOURCEID = "3BB29895-415B-46B6-9ED0-25539308579C";
private static Guid TabResourceId { get { return new Guid(TABRESOURCEID); } }
#endregion properties/variable
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
RadScriptManager.GetCurrent(this).EnablePageMethods = true;
}
public override Guid ResourceId
{
get
{
return PageResourceKeyConfig.SystemSettings;
}
set
{
throw new NotImplementedException();
}
}
#region webmethods
[WebMethod]
public static void UpdateGeneralSettings(TicketSampling TicketSamplingDetails)
{
GeneralSetting objGeneralsetting = null;
objGeneralsetting = new GeneralSetting();
objGeneralsetting.Sampling = new TicketSampling()
{
SamplingPercentage = TicketSamplingDetails.SamplingPercentage,
};
string xmlstring = XMLSerializerHelper.GetAsXMLFromObject<generalsetting>(objGeneralsetting);
string tabname = "General";
SaveSystemSettings(TabResourceId, tabname, xmlstring);
}
#endregion webmethods
private static bool SaveSystemSettings(Guid TabResourceId, string tabname, string xmlstring)
{
bool isSuccess = false;
using (ISystemSettingsManager systemSettingManager = BLFactory.GetInstance<isystemsettingsmanager>(ContextProvider.CurrentContext))
{
isSuccess = systemSettingManager.SaveSystemSetting(TabResourceId, tabname, xmlstring);
}
return isSuccess;
}
I know if i placed above wwebmethod in setting.aspx it will work fine, however i need to place inside .ascx.cs file. How can i achieve this.
Thanks in advance.