.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Namespace problem (code behind "using")

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
Hello! I downloaded sample code from http://www.asp.net/security/tutorials/validating-user-credentials-against-the-membership-user-store-cs and imported the file "Login.aspx" file into my existing project.  This file has in the code behind the following namespaces: view plaincopy to clipboardprint? using System;   using System.Data;   using System.Configuration;   using System.Collections;   using System.Web;   using System.Web.Security;   using System.Web.UI;   using System.Web.UI.WebControls;   using System.Web.UI.WebControls.WebParts;   using System.Web.UI.HtmlControls;   I added a new page (e.g. Login1.aspx) to my project and copied the above to the top of the code behind page (Login1.aspx.cs).  In the downloaded file from the tutorial (Login.aspx) there is this line of code:Membership.ValidateUser(UserName.Text, Password.Text)And at build everything is OK! But if I add excatly the same code in my newly created page (Login1.aspx.cs) I get the following error: Error 9 The type or namespace name 'ValidateUser' does not exist in the namespace 'Krik.Membership' (are you missing an assembly reference?) G:\Krik\Krik\Login.aspx.cs 27 28 Krik The type or namespace name 'Validat

View Complete Post

More Related Resource Links

Razor View Engine and Add Namespace in Web.Config Problem



I am working on a MVC project with Razor view engine and I have the following:


This only works if I have on the same view the following:

  @using SquishIt.Framework;

However, on my Web.Config I have the following:


      <!-- Namespaces -->
        <add namespace="System"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="Microsoft.Web.Mvc"/>
        <add namespace="SquishIt.Framework"/>


So if "SquishIt.Framework" namespace is added on Web.Config why do I need to have the @using on the view?

What's the problem in my javascript's code to get ClientID Property?



 Hi all.

I wirte a simple java script code to get ClientID of controls on the webform. The code is like:

<script type="text/javascript" language="javascript">

var butt = $find("<%= Button1.ClientID %>");



But when i run it , i have a problem. The probmel is:


Server Error in '/' Application.

The Controls collection cannot be modified because t

xmlns:custom="clr-namespace:..." Designview problem

Once adding to simple XAML code reference to it's namespace designer stops work. Is it bug?See sampleThis code shows designer as expected<Window x:Class="Test_CLRNamespace.Window1"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    Title="Test_CLRNamespace" Height="300" Width="300"    >  <Grid>    <Button Margin="41,52,46,62" Name="button1">Button</Button>  </Grid>  </Window>However, this code does not<Window x:Class="Test_CLRNamespace.Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:custom="clr-namespace:Test_CLRNamespace"     Title="Test_CLRNamespace" Height="300" Width="300"     >   <Grid>     <Button Margin="41,52,46,62" Name="button1">Button</Button>   </Grid>   </Window>

namespace of fields problem when creating form template from xml?

I created a form template from a predefined xml, where I do not have any namespace. Later I added more fields. The output xml of the form is for the fields from the xml they have not prefix, for those added later, they have prefix my. I already have them all done. How can I make them consistent to have prefix my? Is there any options in InfoPath to turn on or off the prefix my?   thanks,

Problem in downloading a file code.

hey dere, here is my code.....   void transfer() { string filePath = Server.MapPath("~/download"); string _DownloadableProductFileName = "mob.txt"; System.IO.FileInfo FileName = new System.IO.FileInfo(filePath + "\\" + _DownloadableProductFileName); FileStream myFile = new FileStream(filePath + "\\" + _DownloadableProductFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); string lastUpdateTiemStamp = File.GetLastWriteTimeUtc(filePath).ToString("r"); string _EncodedData = HttpUtility.UrlEncode(_DownloadableProductFileName, Encoding.UTF8) + lastUpdateTiemStamp; Response.Clear(); Response.Buffer = false; Response.AddHeader("Accept-Ranges", "bytes"); Response.AppendHeader("ETag", "\"" + _EncodedData + "\""); Response.AppendHeader("Last-Modified", lastUpdateTiemStamp); Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName.Name); Response.End(); Label1.Text = "hel"; } i have two problems in this code.First while running this code i dont get the file damaged or corrupt. Second problem is dat the code exits at Response.End() and doesnt execute d last line... 

hai i am karthikeyan i have a problem in code

i want to run exe from my application .for that i had pasted my setup in my application . please give solution how to call the exe from my application .......      this is my code-------------------------------------------------------      System.Diagnostics.Process process1 = new System.Diagnostics.Process();         // Set the directory where the file resides         process1.StartInfo.WorkingDirectory = Request.MapPath("C:/Documents and Settings/user9.AIS/My Documents/Visual Studio 2008/WebSites/application/TortoiseSVN-");         // Set the filename name of the file you want to open         process1.StartInfo.FileName = Request.MapPath("TortoiseSVN-");             // Start the process           process1.Start(); -----------------------------------------------------------------   error is this------------------------------------   'C:/Documents and Settings/user9.AIS/My Documents/Visual Studio 2008/WebSites/application/TortoiseSVN-' is not a valid virtual path. &

VS2010 - Problem with WinForms generated code



I'm having trouble with the code that is generated automatically by the WinForms designer, sometimes it generates code that uses the 'components' (IContainer) in the constructors of disposable components and other times it doesn't.

Here is some code. First the code that is generated in a clean new project with just one component on the form:

  private void InitializeComponent()
   this.components = new System.ComponentModel.Container();
   this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
   // errorProvider1
   this.errorProvider1.ContainerControl = this;
   // Form1

Datamanager with WCF Namespace problem



I have written a DataAccess Manager Class which can be used directly in the viewmodel or through a wcf service to get data from db.

I would like to have a switch in my view model to switch between direct or service. For this I implemented an Interface used by the dataaccess manager class and the wcf service definition.

If I try to implement this I get a problem that the namespace of the ServiceClient is showing me that this Interface is in the Service and not in the correct Namespace like this:


instead of


Because of this (or maybe something else) I have to cast the DataServiceClient to (AppInterfaces.IDataAccess) and this is not working...

Does someone has an idea how to get this working?

Thanks for your help.


Beat Wuethrich

Problem opening list RSS through Csharp code



I'm trying to write an application page that loads the RSS feed from a list inside the same SharePoint environment (but in another site collection).
The SharePoint environment uses basic authentication (based on Active Directory).
I do this by using the HttpWebRequest object and I pass through CredentialCache.DefaultNetworkCredentials to authenticate when opening the RSS feed, in order to pass through the credentials of the currently logged on user.

On my test environment this seems to work good. Before I got "unauthorized", and when passing the credentials it would show me the RSS feed.
Now I moved my code to another development server, and there this fails, it still gives me "unauthorized" while I can open the RSS feed manually without any problems. When trying to print the username that is passed through it returns an empty string. I found out on Google that DefaultNetworkCredentials always returns empty values for username/domain/password, but how can I possibly know then what credentials are passed through ???

Or do I have to follow another approach in order to load a list RSS feed that requires authentication ?
I cannot use a fix username/password, as I need to load the RSS feed under the same credentials as the user who opens the application page.

Thanks in advance!

AccordionPane Code Behind Problem



i'm trying to add an AccordionPane in the code behind of my project.

but when trying to set the AccordionPane.Header and  AccordionPane.Content i get an ITemplate error


here is my code:

1    AjaxControlToolkit.AccordionPane test = new AjaxControlToolkit.AccordionPane();
3    test.ID = "test";
4    test.Header = "&lt;a href=\"\" onclick=\"return false;\" class=\"accordionLink\"&gt;User email </a>";
5    test.Content = "List Files here. with download button etc.";
6    Accordion1.Panes.Add(test);


and the error i get is this:

 Error    8    Cannot implicitly convert type 'string' to 'System.Web.UI.ITemplate'  Line 4

 Error    8    Cannot implicitly convert type 'string' to 'System.Web.UI.ITemplate'  Line 5


So does anyone know how i

Security problem while debugging Infopath custom code


I have made a simple InfoPath formular, and in "Submit Options", checked  "Perform custom action using Code", and write some custom code...

Then i run the debug over this code. The InfoPath formular opened in preview mode, and i could successfully step through InternalStartup method.

I did put some data in fields and clicked on "Submit" button. I expected to be continue debugging at the beging of "FormEvents_Sumbit" method, but i got this error message:

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.
   at TEST_FORM2.FormCode.FormEvents_Submit(Object sender, SubmitEventArgs e)
   at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnSubmit(DocReturnEvent pEvent)
   at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnSubmitRequest(DocReturnEvent pEvent)"

After i clicked OK to this error, i got another one, a little different:

"InfoPath cannot submit the form.
The OnSubmitRequest event handler did not work.
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint

jquey code resuse problem


i am using list box and button both are same code but event is different i require that a function create that use both code how to do it,and how to put in seprate file

<script type="text/javascript">
           $(function() {
               $("#<%=list_Target.ClientID %>").change(function() {
                   //$("#<%=list_Target.ClientID %>").val($(this).val());                    				
		   			    $.get("/UserControl/QC_GridView.aspx",{ QcSearch: "" + $('#<%=Hi_QcSearch.ClientID%>').val() + "" },
		        		function(data) {
           $("input[id$='Bu_ShowQc']").click(function() {
                   //$("#<%=list_Target.ClientID %>").val($(this).val());                    				
		   			    $.get("/UserControl/QC_GridView.aspx",{ QcSearch: "" + $('#<%=Hi_QcSearch.ClientID%>').val() + "" },
		        		function(data) {

Namespace Issue in Generated Code


I have a Solution in which I have A WCF Service web site project which then hosts two separate WCF Service Libraries (each in their own project).  One of the Web Services is a Client to the other. 

When I click the ClientService and select Add Service Reference, it all adds properly, but when I go to build it, I get this error in the reference.cs (the generated file).

The type name 'HostWCFService' does not exist in the type 'ClientService.ClientService' C:\Users\...\Reference.cs 

I don't want it to create a ClientService.HostWCFService namespace, I want to be able to use the HostWCFService as its own namespace.  I believe I've had this setup working before at one point; that is, I had this arrangement working before, but am not sure now if the host service was in a sub namespace of the project.

I was able to do: 

using HostWCFService;

instead of

using ClientService.HostWCFService;

Any thoughts? 

Problem trying to execute ALTER SCHEMA from code


I have a visual basic application which needs to make some changes to a SQL Server database (either SQL Server 2005 or 2008).  Specifically, I am trying to eliminate a schema (e.g. MySchema) from the database altogether.  The first thing I must do is move all database objects from 'MySchema' to 'dbo'.  To that end, I execute the command:

ALTER SCHEMA dbo TRANSFER MySchema.ActionsCompleted

I am using an ODBC connection to the database.  There is a user name and password setup on the server that my application uses for all database access.  The error message I get is:

Cannot find the object 'ActionsCompleted', because it does not exist or you do not have permission.

When I run this exact statement from a query in SQL Server Mgmt Studio, it works fine.  The difference is the user (and therefore the permissions).  When I execute from the SQL Server Mgmt Studio, I am effectively an administrator, from my application, I am not.

So, I am trying to figure out what permissions I need to give my application to execute this line.  The documentation says that the user my have CONTROL priviledges over the securable (in this case the table called MySchema.ActionsCompleted) and ALTER priveledges on the dbo schema.  OK, so next I try the following (in SQL Server MGMT Studio):


Interop problem: VB6 COM code functions incorrectly when called from .net code.


I have found recently with some machines or some user accounts that calling some VB6 code from .Net fails to execute properly.
I have two examples:

  1. I have this simple VB6 dll, called by VB.Net code, that calls another simple VB6 dll using createobject.  The second object displays a form modally with progress bars, runs queries against a SQL server database to create and fill a table, and then closes (unload) that progress form and returns the table name.  The first object then takes this data to do additional processing on the SQL server and returns a SELECT statement to the object that called it. 
    For most people this works correctly, however for two users on a terminal server it fails to run correctly.  What it does is not close the form, however all of the updates to the database in both dlls are run according to SQL profiler.  The .Net process that called it never seems to get a return value from the COM dll for those 2 users only.  I even tried to recreate the user's profile, but it did not help.  Note that the .Net code calls the first VB6 dll using CreateObject as well.
    The strangest thing about this is what occurred when I added MsgBox calls to try to determine what was wrong with the progress form.  I added one immediately after the form's status bas was updated to "Finished

Serious problem with this code, please help


This code is going back to query some massive table with about 1 billion records, it looks as though i can use ranking functions for the query as its trying to retrieve the latest record in the history table, using the historyRef column. Can anyone please try rewrite using RANK(), i dont know where to start.


select ic.IndexCodeValue as CodeIndentifier,	
	ic1.IndexCodeValue as Identifier
	ts.[Name] as Position, 
	Current1.Divisor ,
	st.PlanNameShort ,
    ch.ProfileValue as StockCode,
	ch.NumberOfShares ,
	ch.ShareValue ,
	ch.PIF ,

from 	tblProfile i
join	tblProfileInstrument ii on ii.IndexID=i.IndexID
join	tblProfilePositionHistory Current1 on Current1.IndexInstrumentID=ii.IndexInstrumentID 

Problem with populating dropdown in code behind


Hi all, I'm having problems with this code not adding the list items to my dropdown. I was hoping someone could point out why.


On my aspx page I have:

<asp:DropDownList id="AS400_wh_c1_act" runat="server"></asp:DropDownList>

<% PopDrop(AS400_wh_c1_act)%>

In my code behind, I have:

    Public Sub PopDrop(ByVal input As DropDownList)
        input.Items.Add(New ListItem("", ""))
        input.Items.Add(New ListItem("PAGER", "PAGER"))
        input.Items.Add(New ListItem("EMAIL", "EMAIL"))
        input.Items.Add(New ListItem("STANDBY", "STANDBY"))
    End Sub

However, the dropdown list isn't adding the new items.

Anone know what I'm doing wrong?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend