NO Code behind with user control - PLEASE!

A

Amar

Hi,

I have a user Control "Login_Test" which inherits from UserControl.
Within a page i am using it, i locate it with the following code

Recalculate(this);

private void Recalculate(Control Ctrl){
foreach (Control ct in Ctrl.Controls){
if (ct.GetType().ToString() == "ASP.Login_Test_ascx"){
((Login_Test)cr).ReCalculateBalance();
}else{
Recalculate(ct);
}
}
}

And i execute function ReCalculateBalance() of user control. That
works perfect when i am using codebehind. Now i have decided to
make everything inline code with no Codebehing, for better management
and i get the following error

"The type or namespace name 'Login_Test' could not be found (are you
missing a using directive or an assembly reference?)"

My page and the user control is at the same directory so there is no
problem with reference and i cant find out what might be the problem,

Any ideas??
Thanks
 
K

karthick

I think what you did first is right and best practice.

You got to keep the code separate in Code behind and the UI will be
separate. Also, have the UI as thin as possible and move the functions
like ReCalculate to a separate Utility or Helper class which will give
you a chance to reuse in some of the other pages of the same project
and others.

Hth,
Karthick
 
A

Amar

Thanks for the reply,

I finally made it work, i added
<%@ Import Namespace="MyLib"%>

which is the main dll of my project that contains the Userobject also.
As far for this function, i have a BasePage that all pages inherit, that
does the Calculation everytime so i don't have to worry about it, except
the current page that actually changes the Balance runtime and i have to
display the new balance to the user

Thanks anyway
 

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