can I use thih function in separate class

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?
 
G

Grant Merwitz

But of course :)
You can, and you must

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

Guest

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?
 
G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top