can I use thih function in separate class

  • Thread starter Thread starter Jane-Wolf
  • Start date Start date
J

Jane-Wolf

Hi, I have this function and use it for get id of my user company:
public string get_company_from_cookie()
{

string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie =
Context.Request.Cookies[cookieName];
if (null == authCookie) { }

FormsAuthenticationTicket authTicket = null;

try
{
authTicket =
FormsAuthentication.Decrypt(authCookie.Value);
}
catch (Exception ex)
{
string r = ex.ToString();
Err_Label.Text = "The problem is : ex.ToString()";
}

if (null == authTicket)
{
}

string[] userdatax = authTicket.UserData.Split(new char[] {
',' });
string company_number = userdatax[0];
return company_number;
}

I Use it in all pages, can I describe this function in separate class
and then use in all pages?
 
But of course :)
You can, and you must

Just be sure you reference the classes you need, and you can do anything!!
 
You create a base class which inherits from UI.Page and can add this function
in that class. Then create your own pages by inheriting the base class.

Thanks,
Ragu

Grant Merwitz said:
But of course :)
You can, and you must

Just be sure you reference the classes you need, and you can do anything!!



Jane-Wolf said:
Hi, I have this function and use it for get id of my user company:
public string get_company_from_cookie()
{

string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie =
Context.Request.Cookies[cookieName];
if (null == authCookie) { }

FormsAuthenticationTicket authTicket = null;

try
{
authTicket =
FormsAuthentication.Decrypt(authCookie.Value);
}
catch (Exception ex)
{
string r = ex.ToString();
Err_Label.Text = "The problem is : ex.ToString()";
}

if (null == authTicket)
{
}

string[] userdatax = authTicket.UserData.Split(new char[] {
',' });
string company_number = userdatax[0];
return company_number;
}

I Use it in all pages, can I describe this function in separate class
and then use in all pages?
 
Hi,

Create the base class and write the same function in it and call as many
places on your code by creating the object of that class.

Regards,
Sachin Saki
..NET Developer - Capgemini, INDIA

"Ragunathan" ने लिखा:
You create a base class which inherits from UI.Page and can add this function
in that class. Then create your own pages by inheriting the base class.

Thanks,
Ragu

Grant Merwitz said:
But of course :)
You can, and you must

Just be sure you reference the classes you need, and you can do anything!!



Jane-Wolf said:
Hi, I have this function and use it for get id of my user company:
public string get_company_from_cookie()
{

string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie =
Context.Request.Cookies[cookieName];
if (null == authCookie) { }

FormsAuthenticationTicket authTicket = null;

try
{
authTicket =
FormsAuthentication.Decrypt(authCookie.Value);
}
catch (Exception ex)
{
string r = ex.ToString();
Err_Label.Text = "The problem is : ex.ToString()";
}

if (null == authTicket)
{
}

string[] userdatax = authTicket.UserData.Split(new char[] {
',' });
string company_number = userdatax[0];
return company_number;
}

I Use it in all pages, can I describe this function in separate class
and then use in all pages?
 
Back
Top