Class not available - asp.net

İ create a project "Deneme". create a folder as "App_Code" and create a class Islem in this folder. Then i create new aspx page but i couldn't see this class.error message is "Deneme is available Deneme is not availabe" I couldn't understand. My friend cab see this class on his computer but I can't. I created a new webform default.aspx. I couldn't reach this class, but I can reach webform1.aspx in this folder.

provide namespace in your Islem.cs like this
namespace Deneme
{
public class Islem
{
// .... logic
}
}
create new class in App_Code folder, there is no namespace by default. so you can no access it.

Troubleshooting when you can't find a class
While working on the project, open the "Object Browser" from the "View" menu. Then in the textbox labeled "Search" type in "Islem" and see what comes up.
If the class doesn't come up at all, you're in the wrong project, or you didn't add the class like you think you did, or it's a different project and you need to add a reference.
If it does come up, take careful note of the class' complete namespace.
My guess
My guess is that you have a mismatch on the namespace. By creating the folder you created a sub-namespace by default, so you probably need to add something like this to the top of your code:
using Deneme.App_Code
or, if you don't want to add that for some reason, you can instantiate an instance of the class using its full name:
var o = new Deneme.App_Code.Islem();
Another guess
Make sure Islem.cs is set to compile. See this answer for instructions.

This is a weird situation but try this. Go to 14 line in your Default.aspx.cs file and press ctrl+.+enter then you will have a new Islem file i the root of your project. Rebuild and then your error will disappear. Then copy the code inside your original Islem to the new generated file. Remove the old Islem and move the new one to App_Code. Hope this help you.

Related

Weird error when creating new Action Script class

Good Morning,
I have a very odd error working in adobe flexbuilder 3.
Ever since yesterday when ever I create a new class, Flex builder do not see anything wrong in my class.
how do i create one:
Right click on a folder in the package hierarchy
--> new
--> action script class
I leave everthing as is but i give it a name obviously
finish
The class is created.
I can now type anything into this class... Even the words "abc" and flex builder do not see that this is wrong.
if i go to an existing class and type "abs" , the moment i hit save it complains about the "abc"
I have tried the following but the problem still persists.
Deleted my workspace and created a new one and re-import.
If i right click on the class in the Flex navigator the "inlcude class in library" is greyed out.
if anyone can give me an idea, even if it is silly, please do. I really need to be able to add new classes.
thanks
The new class that i have created looks like
package za.co.dcs.cib.das.application.vo.authorisation.appDetails.memberDetails
{
public class MyNewlyTestClass
{
public function MyNewlyTestClass()
{
}
}
}
and then i add "ABC" to it... to which it don't complain about. I can add just about anything i want to this class... and nothing is ever an error.
package za.co.dcs.cib.das.application.vo.authorisation.appDetails.memberDetails
{
public class MyNewlyTestClass
{
public function MyNewlyTestClass()
{
abc
}
}
}
Or if i remove the function
package za.co.dcs.cib.das.application.vo.authorisation.appDetails.memberDetails
{
public class MyNewlyTestClass
{
public MyNewlyTestClass()
{
}
}
}
Flash Builder is plain stupid. The ide does not translate the ActionScript into an abstract syntax tree when typing, only check for the syntax when saving.
Don't know if this is default behavior but what i have found is that...
If I change an existing class the compiler checks the syntax but if I add a random file the compiler will only check the file if that file is used by my application.
I have tried this and it seems to work. The moment that you call that file from within your application it validates and give me errors where should be.
Thanks for all your updates

adding implementation and header files

Hi all i have created my code etc for the .h/.m that are all ready provided. But i would like to known how to add more because when i add a view controller to my storyboard. I can't have code in it i think what I'm looking for is called a second view controller .h/.m. I am creating a project in Xcode 4.2 and its a single view based application. I'm new to this but i think what i have said makes sense thanks for your time.
kind regards
open your project
press command+N to open the new file dialog
iOS > CocoaTouch
Class = YOUR_CLASS_NAME
Subclass of = SUBCLASS_TYPE (e.g. UIViewController)
etc.

Custome activity buid by an activity file

How can I use custom code (activity file not codeactivity neither activitydesginer ) as an Activity inside a Reshosted workflow designer?
I was doing the following for any activity, which I build for each ( codeactivity & activitydesginer) files, and wirte:
new ToolboxCategory("new Toolbox")
{
Tools=
{
new ToolboxItemWrapper(typeof(Flowchart)),
new ToolboxItemWrapper(typeof(SimpleWebDesigner.TEST)),
....etc
AnyHelp?
If you're talking about loading an Activity loaded from a loose xaml file, you can do this.
You have to use the the ActivityXamlServices class to Load(filename) the file at runtime. When you do this, you get the deserialized Activity instance. Of course, you must have any relevant assemblies (any assembly referenced by Activities defined in the xaml file) either loaded in the AppDomain or available for loading where the Fusion loader can find them.
Once you do this, you can create a ToolboxItemWrapper passing in activityInstance.GetType().
One thing, since the Activity xaml file is an Activity which holds other Activities, you will get the default Designer, which only shows a blank header. There is no easy way* to expand the child Activities defined in the xaml file in the designer when you drop them on the design surface.
*I believe you can construct a class that implements IActivityTemplateFactory which you can pass to the ToolboxItemWrapper which can pass the root Activity defined within your xaml file, so that when you drag/drop the item from the toolbox it will automatically add all child Activities defined in the xaml file. But I've never done this and am not sure if you can.

MVVM Light + Blend designer view error: Cannot find resource named 'Locator'.

The application runs fine but i could not see my design in the designer view.
It says Cannot find resource named 'Locator'. Obviously, i did not change anything in the code, i just did the data binding using the data binding dialog...
anyone facing the same problem?
There are two known occurrences where this can happen.
If you change to Blend before you built the application, the DLLs are not available yet and this error can be seen. Building the application solves the issue.
There is a bug in Expression Blend where, if you are placing a user control in another user control (or Window in WPF), and the inner user control uses a global resource, the global resource cannot be found. In that case you will get the error too.
Unfortunately I do not have a workaround for the second point, as it is a Blend bug. I hope we will see a resolution for that soon, but it seems to be still there in Blend 4.
What you can do is
Ignore the error when working on the outer user control. When you work on the inner user control, you should see the design time data fine (not very satisfying I know).
Use the d:DataContext to set the design time data context in Blend temporarily.
Hopefully this helps,
Laurent
I've come up with a reasonably acceptable workaround to this problem since it doesn't appear to have been fixed in Blend 4:
In the constructor for your XAML UserControl just add the resources it needs, provided you're in design mode within Blend. This may be just the Locator, or also Styles and Converters as appropriate.
public partial class OrdersControl : UserControl
{
public OrdersControl()
{
// MUST do this BEFORE InitializeComponent()
if (DesignerProperties.GetIsInDesignMode(this))
{
if (AppDomain.CurrentDomain.BaseDirectory.Contains("Blend 4"))
{
// load styles resources
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "Resources/Styles.xaml"), UriKind.Absolute);
Resources.MergedDictionaries.Add(rd);
// load any other resources this control needs such as Converters
Resources.Add("booleanNOTConverter", new BooleanNOTConverter());
}
}
// initialize component
this.InitializeComponent();
}
There may be some edge cases, but its working OK for me in the simple cases where before I'd get a big red error symbol. I'd LOVE to see suggestions on how to better solve this problem, but this at least allows me to animate user controls that otherwise are appearing as errors.
You could also extract out the creation of resources to App.xaml.cs:
internal static void CreateStaticResourcesForDesigner(Control element)
{
if (AppDomain.CurrentDomain.BaseDirectory.Contains("Blend 4"))
{
// load styles resources
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "Resources/Styles.xaml"), UriKind.Absolute);
element.Resources.MergedDictionaries.Add(rd);
// load any other resources this control needs
element.Resources.Add("booleanNOTConverter", new BooleanNOTConverter());
}
}
and then in the control do this BEFORE InitializeComponent():
// create local resources
if (DesignerProperties.GetIsInDesignMode(this))
{
App.CreateStaticResourcesForDesigner(this);
}
Note: At some point in time this stopped working for me and I ended up hardcoding the path to the Styles.xaml because I got frustrated trying to figure out which directory I was in.
rd.Source = new Uri(#"R:\TFS-PROJECTS\ProjectWPF\Resources\Styles.xaml", UriKind.Absolute);
I'm sure I could find the right path with 5 minutes work, but try this if you're at your wits end like I was!
In MyUserControl.xaml, instead of:
DataContext="{Binding Main, Source={StaticResource Locator}
use:
d:DataContext="{Binding Main, Source={StaticResource Locator}
where "d" has been previously defined as:
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
The reason and workaround explained here
http://blogs.msdn.com/b/unnir/archive/2009/03/31/blend-wpf-and-resource-references.aspx
Look at (b) part of the post.
I had a similar problem with a user control resource.
I added this in my usercontrol xaml code:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GinaControls;component/Resources/GinaControlsColors.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
Where GinaControls is the namespace where the control class is declared and /Resources/GinaControlsColors.xaml is the project folder and xaml resource file name.
Hope this helps.
Just add this in your App.xaml.cs at the very beginning
here's my piece of code
[STATThread()]
static void main(){
App.Current.Resources.Add("Locator", new yournamespace.ViewModel.ViewModelLocator());
}
public App(){
main();
}
Make sure the Blend has opened the entire solution and NOT just the single project containing the views. I was right-clicking in Visual Studio and selecting Open In Expression Blend. To my surprize, Blend could not find the solution file, so it only opened the single project.
When I realized this, I launched Blend directly, pointed it to the solution file, and then Blend was able to find the ViewModelLocator in my view.

How to Rename my asp.net web page

I have a page name with XYZ.aspx
Now I want to change ABC.aspx how should I do it?
When i directly change it from solution explorer it gives me an error.
Can anyone help me on this?
Thank You
Smartdev
ASP.NET files are usually composed of 1-3 files total depending on the type of project and the file itself. That being said, there is always the markup *.aspx file, then optionally there will be a code-behind *.aspx.cs file and an additional and also optional designer file *.aspx.designer.cs. If you are renaming the file you will need to update code in various places based on the structure of the file itself.
In the event of more than 1 file making up your ASP.NET page you will want to update the .aspx file's header like so:
<%#Page CodeBehind="XYZ.aspx.cs" Inherits="XYZ" %>
to
<%#Page CodeBehind="ABC.aspx.cs" Inherits="ABC" %>
Then in the code behind file
public partial class XYZ : Page { }
to
public partial class ABC : Page { }
Finally, if there is also a *.designer.cs file you will want to update it as well:
public partial class XYZ : Page { }
to
public partial class ABC : Page { }
That should cover all of the files!
To change the name of an aspx file (I'm using vs2012) and associated files single click on filename in solution explorer and single click again to select the name of the file, change the name and enter... vs will rename the code behind file and designer file automatically and change the tags linking them. As nathan above said it does not rename the c# in the code behind to reflect the filename (which would be good practice)... nor importantly does it do a solution wide search for links and more oblique code references to the file. So it's best to do a manual find in files over the entire solution to check and all naming conventions are good.
That should do it

Resources