Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all 3938 articles
Browse latest View live

How to develop Time Scheduler in asp.net web application?

$
0
0
I am working on asp.net web application project. I want to develop a web page names as ApplyRulePage.aspx. User will apply rules (Rule has Start Time and End time) by uploading file. A Rule is defined for a period of time(From Start time to End time). lets say Rule is applied from a start time to end time(lets say from 14:56:59 March 1 2013 to 15:34:21 April 2013). User can apply multiple Rules if time span of Rules are mutually exclusive(means time is not clashing), So in this way We can apply any number of Rules for the User. But If lets say one Rule is applied and User wants to apply a new Rule and if time period of this new Rule is clashes with the Old Rule then We will give a message to the User that Old Rule will be deleted and new Rule will be applied and if time periods are not clashing it will so both Rule on Page.
 
So basic requirement is for a particular time period only one Rule should be applied.
 
My question here is how to implement this feature in asp.net. How well I can render page to the User so that it looks pretty good and For User it should be very easy to understand what exactly is happening on UI. If it could be achieved by javascript, jquery, ajax or some other programming, please let me know. If there is any link for a sample project or example please let me know. Sorry for such a stupid question actually I am learning asp.net by self and I have nobody to ask.

a prefix of _ctl0_ to an asp.net link button

$
0
0
Hello Guys,
 
I have a simple asp.net page with an asp.net link button and asp.net content tag which point to a simple asp.net master page with an asp.net content place holder and a form tag. Here is the code of these two items:
 
Site.Master:
 
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebApplication1.SiteMaster"%> 
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title></head><body><formrunat="server"><asp:ContentPlaceHolderID="MainContent"runat="server"/></form></body></html>
 
Default.aspx:
 
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default"%> 
<asp:ContentID="BodyContent"runat="server"ContentPlaceHolderID="MainContent"><asp:LinkButtonID="LinkButton1"runat="server">LinkButton</asp:LinkButton></asp:Content>
 
From some reason when we run this simple web application on one server the id the link bhutton get is MainContent_LinkButton1
and when we run this application on another server the id the link button get is _ctl0_MainContent_LinkButton1
 
Doese someone have an idia why we get the prefix _ctl0_ in a specific server and in another server we don't get it?

web api - global.aspx error - does not contain a constructor that takes 0 arguments

$
0
0
I am trying implement basic authentication method in web api and I currently in stage of reading user details from the database. I am expericing the following issue ('API.UserPro' does not contain a constructor that takes 0 arguments - error ) at the moment in the global.aspx:
 
protected void Application_Start()
{
GlobalConfiguration.Configuration
.MessageHandlers.Add(new BasicAuthMessageHandler()
{
PrincipalProvider = new UserPro()
});
 

publicclass UserPro : IProvidePrincipal
    {
 
        private User _userRepo;
 
        public UserPro (User userRepo)
       {
        this._userRepo = userRepo;
       }
 
        public IPrincipal CreatePrincipal(string username, string password)
        {
            try 
            {
                if (!_userRepo.Validate(username, password))
                {
                    returnnull;
                }
 
                else
            {
                var identity = new GenericIdentity(username);
                IPrincipal principal = new GenericPrincipal(identity, new[] { "Admin" });
 
                return principal;
            }
        }
        catch
        {
            returnnull;
        }
        }   
    }
}
 
Any advice or suggestion would be very helpful. Many thanks in advance.

Upload file to SQL database using html5

$
0
0
Hi I've been searching awhile but haven't found what I was looking for. I am trying to upload a file to SQL database using HTML5 <inputtype=file>. I have the html5 side done but am looking for a resource or example of server side code that will upload the file to a SQL server. I know I'll using httpwebrequest. Do I use a webservice (asmx file)? a handler (axhx file)? or something else?
 Thank you!
 John

on hover on menu items

$
0
0
i want to set the menu items in center on hover event.

How to call a Phython Script from .Net

$
0
0
I am Working on an ASP.Net website with c#.Net as Code Behind where I need to Call a phython script which does some business logic. Can anyone please tell me how to call a phython script from ASP.Net website.<u></u>

how to add data in listbox sql server using store procedure

$
0
0
hiii!!! i want to fatch data in list box.. the selection based on dropdown list .. if we select value in drop down then required data will be fatch in list box.. the required data will be fatch accroding to userttype value ..the values of usertype=1,2. i m using 3 layer architecture...
 

 
my store procedure
USE [SCJ]
GO
/****** Object: StoredProcedure [dbo].[sp_sendmail] Script Date: 02/10/2014 12:34:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:<author,,name>
-- Create date:
-- Description:<description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sp_sendmail]
-- Add the parameters for the stored procedure here
(
@usertype INT
--@emailid nvarchar(50)='',
 
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
BEGIN
-- Insert statements for procedure here
if(@usertype='usertype')
SELECT emailid from Login_User_Info where LTRIM(RTRIM(usertype)) = LTRIM(RTRIM(@usertype))

END
END

about source code

$
0
0
source code for sending sms in asp.net plz tell me

Aes Encryption fails

$
0
0
why does this function fails, with CipherMode.OFB where as it works with CipherMode.ECB

PublicFunction EncryptAES(sIn AsString, sKey AsString) AsStringDim AES AsNew RijndaelManaged()
        Dim ahashMD5 AsNew MD5CryptoServiceProvider()
        AES.Key = ahashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(sKey))
        AES.Mode = CipherMode.OFB
        Dim AESEncrypt As ICryptoTransform = AES.CreateEncryptor()
        Dim aBuffer AsByte() = System.Text.ASCIIEncoding.ASCII.GetBytes(sIn)
        Return Convert.ToBase64String(AESEncrypt.TransformFinalBlock(aBuffer, 0, aBuffer.Length))
    EndFunction
 
Error Message : Specified cipher mode is not valid for this algorithm.
Regards,
Vishal

web api c# - error

$
0
0
I am trying to call the following method (api/test?name=user1) but I keep getting the 'unsuccessful' response. I have tried debugging the method and found it crashes on the 'mes' unsuccessful line. there is data retrieved from the database in the result variable but on the client-end it keeps showing 'unsuccessful' message.
 
public HttpResponseMessage GetName(string name)
        {
           User layer = new User();
 
            var result = layer.GetData(name);
 
            if (result.username != null)
            {
                var mes = string.Format("unsuccessful");
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, mes);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.OK, result);
            }
                
        }
 
Is their something I am missing?
Many thanks.

Time Table

$
0
0
i want time table in Gridview...it have in the follwoing format
 

Date 1,Date 2 ...
Period
7.30-8.30 sub1
8.30-9.30
........
.........
if any one have an idea please share it

ASPNET AJAX sys.webserver configuration for NET 4+

$
0
0
I am calling pageMethod in codebehind of aspx page. I get the response for whole page instead of webMethod response. Also, I tried calling the same webMethod using jquery and got the whole page as response.
 
I am using .NET 4.5.1 and IIS7.5 and I think the issue is realted to in built extensionless URLS in VS2013
 
i am using the following sys.webserver config
<system.webServer><validationvalidateIntegratedModeConfiguration="false"/><modulesrunAllManagedModulesForAllRequests="true"><removename="ScriptModule"/><addname="ScriptModule"preCondition="managedHandler"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></modules><handlers><removename="ExtensionlessUrlHandler-Integrated-4.0"/><removename="OPTIONSVerbHandler"/><removename="TRACEVerbHandler"/><addname="ExtensionlessUrlHandler-Integrated-4.0"path="*."verb="*"type="System.Web.Handlers.TransferRequestHandler"preCondition="integratedMode,runtimeVersionv4.0"/></handlers></system.webServer>
 
can any one send me correct configuration for ASPNET AJAX or Jquery ajax for .NET 4+ and IIS 7+

Plz help for button data insert in to table...

$
0
0
I have two button and i want to insert those data into data base in asp.net c#

This Control is invalid -Error

$
0
0
I have a requiredfield,range and regular exp validator added and then added each ValidatorCalloutExtender for each validator.
 
First time when I giving invalid data for rate text box it is showing "This Control is invalid".
 
Please help. Thanks

web api - basic authentication (principal error)

$
0
0
Hi,
 
I am trying to get the following code read credentials from the user class but I experiencing the following principal error -- "The name 'PrincipalProvider' does not exist in the current context".
 
publicclass BasicAuthMessageHandler : DelegatingHandler
    {
        bool _RequireSsl = true;
        publicbool RequireSsl
        {
            get { return _RequireSsl; }
            set { _RequireSsl = value; }
        }
        
        privateconststring BasicAuthResponseHeader = "WWW-Authenticate";
        privateconststring BasicAuthResponseHeaderValue = "Basic";
 

        [Inject]
        public iUser Repository { get; set; }
 

        protectedoverride System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            AuthenticationHeaderValue authValue = request.Headers.Authorization;
            if (authValue != null&& !String.IsNullOrWhiteSpace(authValue.Parameter))
            {
                api_login parsedCredentials = ParseAuthorizationHeader(authValue.Parameter);
                if (parsedCredentials != null)
                {
                    Thread.CurrentPrincipal = PrincipalProvider
                        .CreatePrincipal(parsedCredentials.username, parsedCredentials.password);
                }
            }
            returnbase.SendAsync(request, cancellationToken)
                .ContinueWith(task =>
                                  {
                                      var response = task.Result;
                                      if (response.StatusCode == HttpStatusCode.Unauthorized
                                          && !response.Headers.Contains(BasicAuthResponseHeader))
                                      {
                                          response.Headers.Add(BasicAuthResponseHeader
                                                               , BasicAuthResponseHeaderValue);
                                      }
                                      return response;
                                  });
        }
 
        private api_login ParseAuthorizationHeader(string authHeader)
        {
            string[] credentials = Encoding.ASCII.GetString(Convert
                                                                .FromBase64String(authHeader))
                .Split(
                    new[] { ':' });
            if (credentials.Length != 2 || string.IsNullOrEmpty(credentials[0])
                || string.IsNullOrEmpty(credentials[1])) returnnull;
            returnnew api_login()
                       {
                           username = credentials[0],
                           password = credentials[1],
                       };
        }
 

        privatebool Authenticate(HttpContextBase context)
        {
            if (_RequireSsl && !context.Request.IsSecureConnection && !context.Request.IsLocal) returnfalse;
 
            if (!context.Request.Headers.AllKeys.Contains("Authorization")) returnfalse;
 
            string authHeader = context.Request.Headers["Authorization"];
 
            IPrincipal principal;
            if (TryGetPrincipal(authHeader, out principal))
            {
                HttpContext.Current.User = principal;
                returntrue;
            }
            returnfalse;
        }
 
        privatebool TryGetPrincipal(string authHeader, out IPrincipal principal)
        {
            var creds = ParseAuthHeader(authHeader);
            if (creds != null)
            {
                if (TryGetPrincipal(creds[0], creds[1], out principal)) returntrue;
            }
 
            principal = null;
            returnfalse;
        }
 
        privatestring[] ParseAuthHeader(string authHeader)
        {
            // Check this is a Basic Auth header 
if (authHeader == null || authHeader.Length == 0 || !authHeader.StartsWith("Basic")) returnnull;
 
            // Pull out the Credentials with are seperated by ':' and Base64 encoded 
string base64Credentials = authHeader.Substring(6);
            string[] credentials = Encoding.ASCII.GetString(Convert.FromBase64String(base64Credentials)).Split(newchar[] { ':' });
 
            if (credentials.Length != 2 || string.IsNullOrEmpty(credentials[0]) || string.IsNullOrEmpty(credentials[0])) returnnull;
 
            // Okay this is the credentials
return credentials;
        }
 
        privatebool TryGetPrincipal(string userName, string password, out IPrincipal principal)
        {
            // this is the method that authenticates against my repository (in this case, hard coded)
// you can replace this with whatever logic you'd use, but proper separation would put the
// data access in a repository or separate layer/library.
            api_login user = Repository.Validate2(userName, password);
 
            if (user != null)
            {
                // once the user is verified, assign it to an IPrincipal with the identity name and applicable roles
                principal = new GenericPrincipal(new GenericIdentity(user.username));
                returntrue;
            }
            else
            {
                principal = null;
                returnfalse;
            }
        }
 
User class methods:
 
public api_login GetData(string userName)
{
return db.api_login.FirstOrDefault(c => c.username == userName);
}
 

public api_login Validate2(string userName, string Password)
{
 
return db.api_login.FirstOrDefault(u => u.username == userName && u.password == Password);
}
 
Many thans for your help and time.

How to insert a .swf file in a ASP.Net page

$
0
0
As a part of my website, I need to diaplay a .swf file in my home page. Could anyone please tell me how to insert the .swf file in ASP.Net page

About gate way

$
0
0
plz tell me any one , The name of the free sms sending gateways for sending sms from different free sms web site

Select multiple row of gridview using Shift+select functionality without using checkboxes.

$
0
0
I want to select multiple rows of gridview using shift+select functionality. My condition is that there are no checkboxes. The user has to select the user on clicking the row and that row's color should change accordingly. Can anyone help? I am looking for this functionality from a long time. I have been able to get this functionality using checkboxes but that is not what i want.reply me pls.

I am getting RSAProtection Error, please help me

$
0
0
Hi All,
Its killing my time I have been freaking with it, for some time I was a using a computer in which I didn't have this problem. Now my company gave me new computer I started getting this problem. Since two days I am just dieing to run my application. Without running my application what can I do? I just don't want any encryption and decryption on my machine, if they want to do it on the Server let them do it. If I want to say I don't want to play with any encryption or decryption where can I say that. Why the heck isn't simple to say that I don't want it. I have been researching, but every one is explaining how to encrypt or decrypt but no one is saying how just get out of it. I don't want it that's it.
 
I have an asp.net application, I don't want to encrypt or decrypt my web config file, but still I am getting the following error. How can I say that I want neither encryption nor decryption for my application on my machine.
I went into Machine.Config file and commented the RSA Encryption section as below
<!--<configProtectedData defaultProvider="RsaProtectedConfigurationProvider">
        <providers>
            <add name="RsaProtectedConfigurationProvider" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" keyContainerName="NetFrameworkConfigurationKey" cspProviderName="" useMachineContainer="true" useOAEP="false"/>
            <add name="DataProtectionConfigurationProvider" type="System.Configuration.DpapiProtectedConfigurationProvider,System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" description="Uses CryptProtectData and CryptUnProtectData Windows APIs to encrypt and decrypt" useMachineProtection="true" keyEntropy=""/>
        </providers>
    </configProtectedData>-->
And my Web config doesn't have any encrypt or decrypt functionality defined as below.
<add key="SqlServerConnectionString" value="data source=xxxxSQLTEST\Prod;initial catalog=xxxx;password=xxxxxxxxxxx;persist security info=True;user id=xxxxxx"/>
    <add key="OracleConnectionString" value="data source=xxxx;password=incnpdev;user id=xxxxx"/>
    <add key="OleDbConnectionString" value="data source=(local);initial catalog=xxxxxx;password=xxxxxx;persist security info=True;user id=xxxxx"/>
Here is the following Error I am getting.
Server Error in'/apps/cnpweb/zzfdpsource/ORFdpProd' Application.
--------------------------------------------------------------------------------
 
Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 
 
Parser Error Message: An error occurred loading a configuration file: The protection provider 'RsaProtectedConfigurationProvider' was not found.
 
Source Error: 
 

[No relevant source lines] 
 
Source File: C:\inetpub\localinternet\webcon.config    Line: 0 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18067
 
But if I keep the RSA section in the machine config file I am getting the following error. Why MS creates things like this. I don't even understand what is wrong. I the old machine I was not having this error, but when I got new machine to work on I am getting the following error. The same settings are there on every other developers machine they are not getting any error. This is making me nervous. Is my machine is incorrect what is wrong?
 
Server Error in'/apps/cnpweb/zzfdpsource/ORFdpProd' Application.
--------------------------------------------------------------------------------
 
Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 
 
Parser Error Message: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Bad Data.
 

Source Error: 
 

Line 2:  <!-- External Connection Strings from Microsoft: http://msdn.microsoft.com/en-us/library/ms254494(VS.80).aspx -->
Line 3:  <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
Line 4:   <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
Line 5:    xmlns="http://www.w3.org/2001/04/xmlenc#">
Line 6:    <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" /> 
 
Source File: C:\inetpub\localinternet\webcon.config    Line: 4 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18067
 
When I am trying other thing I am getting the following error.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>aspnet_regiis -pa "NetFrameworkConfigurationKey""ASPNET"
Microsoft (R) ASP.NET RegIIS version 4.0.30319.17929
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Adding ACL for access to the RSA Key container...
No mapping between account names and security IDs was done. (Exception from HRESULT: 0x80070534)
Failed!
With all these error messages if someone can give me any idea or link or any sort of help. I will be very very thankful. I don't know what to do? I am researching heavily but no clue till now. Please help me, thanks in advance.
Thanks & Regards,
 
Abdul Aleem Mohammad
St Louis MO - USA

source code

$
0
0
I need source code for sending sms using asp.net C# through gsm modem or Boardband of any brand please any one help
Viewing all 3938 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>