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

How can I properly use the Trace.Write() method inside of my for loop to print month and future values?

$
0
0
I am struggling with trying to figure out how I can output a trace message in ASP.NET using the Trace.Write() method inside of a for loop in order for a user to see the future value after 1 month, 10 months, and 50 months? The format should be like this:
Month{i}: & Value{futureValue}. So, for example, the format should look like this after the first month: "Month:" {i} "Value:"{futureValue}. i know that's not right but that's why I need help understanding how I can input the variables correctly into this method. I have researched my problem, but it's not specific to my individual problem. Here is the site I have researched before coming here: (http://www.c-sharpcorner.com/UploadFile/225740/how-to-write-custom-tracing-message-in-Asp-Net/)

<pre lang="c#"><pre>namespace XEx05FutureValue
{
    publicpartialclass Default : System.Web.UI.Page
    {
        protectedvoid Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                for (int i = 50; i <= 500; i += 50)
                    ddlMonthlyInvestment.Items.Add(i.ToString());
        }
 
        protectedvoid btnCalculate_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                int monthlyInvestment = Convert.ToInt32(ddlMonthlyInvestment.SelectedValue);
                decimal yearlyInterestRate = Convert.ToDecimal(txtInterestRate.Text);
                int years = Convert.ToInt32(txtYears.Text);
 
                decimal futureValue = this.CalculateFutureValue(monthlyInvestment,
                    yearlyInterestRate, years);
 
                lblFutureValue.Text = futureValue.ToString("c");
            }
        }
 
        protecteddecimal CalculateFutureValue(int monthlyInvestment,
        decimal yearlyInterestRate, int years)
        {
            int months = years * 12;
            decimal monthlyInterestRate = yearlyInterestRate / 12 / 100;
            decimal futureValue = 0;
            for (int i = 0; i < months; i++)
            {
                futureValue = (futureValue + monthlyInvestment)
                    * (1 + monthlyInterestRate);
                if (Trace.IsEnabled)
                {
                    Trace.Write({i} {futureValue});
                }
            }
            return futureValue;
        }
 
        protectedvoid btnClear_Click(object sender, EventArgs e)
        {
            ddlMonthlyInvestment.SelectedIndex = 0;
            txtInterestRate.Text = "";
            txtYears.Text = "";
            lblFutureValue.Text = "";
        }
    }
}

                       

vb.net 2010 web form app point to correct .net framework

$
0
0
I just started to be assigned a work station that was low on memory so I accidently removed the wrong version of the .net framework. To correct the problem, I downloaded .net framework 4.0 since that is what the application uses. This web form application uses vb.net 2010 visual studio ide. 
I problem is I probably downloaded the wrong version. The application probably was using a version number 4.3 I am guessing. 
Thus I am trying to determine what I need to do to solve the problem.
Here is where the steps of where the problem lies:
'retarget the project to .net framework 4.0. After the project opens, you can retarget the
1. When I try to debug the application, I get the following error message:
”Retarget the project to .net framework 4.0.

Once I see the above message, I just click the OK button. I do not know where to point the application.
2. After that point I get lots of messages that look like the following:
AttendanceLetters\App_Code\mylistbox.vb(1): Build (web): Reference assemblies for target .NET Framework version not found; please ensure they are installed, or select a valid target version.
Thus  to solve the problem can you tell me the following:
1. Can you tell me and/or point to a url (link) that will solve the problem tell me how and/or how to point the application to the correct target link?
2. If that is not possible, do I need to download some version of the .net framework that the application is expecting to see? If so, how can I tell what version the application is looking for?
3. If the above solutions do not work. should I uninstall the visual studio 2010 that is on this workstation and reinstall a new version so that the application can find the correct version of the .net framework?
4. If you have a different solution would you tell me what I should do to solve the problem?

Need a article on repository and data access code unit testing

$
0
0
googled first but do not find any suitable one. so looking for a details article on repository and data access code in dotnet core unit testing
where we will not use any 3rd part library like mock or effort rather use anything built-in.

anything exist such like ?

can we unit test repository and data access code with intellitrace ? share idea. thanks

Dot Net Core 1.1 Static files(css,fonts,js) are not getting loaded when I am deploying my site in a Sub Domain

$
0
0
Hi,

I created a website in Dot Net Core 1.1.

If I am deploying my site on domain directly all static files are getting loaded and my website is running fine but as I am deploying my website in sub domain, none of the static file(css, fonts, js) is getting loaded.

Really appreciate your help in advance.

Unable to cast object of type 'System.DBNull' to type 'System.String'.

$
0
0
I have this RadioButtonList in Repeater control.

We are using Repeater control dynamically add new rows. I seem to handle projects where rows are dynamically added Smile | :)

In any case, when a record is added for the first time for just one row, there are no issues with this line of code:

<asp:RadioButtonList ID="rdlmhorsepType" Text='<%#string.IsNullOrEmpty((string)Eval("rdlmhorsepType")) ? "Recoil" : Eval("rdlmhorsepType") %>' runat="server" ValidationGroup ="stype" RepeatDirection="Horizontal" TextAlign="Right" style="display:inline;">


However, when one row is filled with data and another row is added, I run into the following error messages:
able to cast object of type 'System.DBNull' to type 'System.String'.

While I am at this, is there a way to populate dynamically populated dropdownlist in Repeater?

I have this:
<asp:DropDownListID="ddlPrevState"cssClass="disabledcss"runat="server"AppendDataBoundItems="True"><asp:ListItemValue=""Selected="True"></asp:ListItem></asp:DropDownList>


Here is C# code:
//I query the db in pageload() event: 
       //We query the DB only once in the Page Load
       con = new SqlConnection(ConfigurationManager.ConnectionStrings["ppmtest"].ToString());
       string sSQL = "Select sID,sName from states ORDER By sName ASC";
       // Response.Write(sSQL);//Response.End();
       SqlCommand cmd3 = new SqlCommand(sSQL, con);
       con.Open();
       cstable = new DataTable();
cstable.Load(cmd3.ExecuteReader());
  
  //Then I call it in ItemDataBound...) eventprotectedvoid repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
      {
          var ddlPState = (DropDownList)e.Item.FindControl("ddlPrevState");
          ddlPState.DataSource = cstable;
          ddlPState.DataTextField = "sName";
          ddlPState.DataValueField = "sID";
        ddlPState.DataBind();


Any ideas how to resolve this?

Thanks as always

My service move my file Location but doesn't upload the data in sql server... here is my code

$
0
0
<pre>using System;
using System.ServiceProcess;
using System.Data.SqlClient;
using System.IO;
using System.Timers;
using System.Configuration;
using System.Data.OleDb;
using System.Data;
 

 

namespace MoveToDesiredDest
{
    publicpartialclass Service1 : ServiceBase
    {
        long delay = 5000;
        protectedstring LogPath = ConfigurationManager.AppSettings["LogPath"];
        protectedstring MoveFilePathPath = ConfigurationManager.AppSettings["MovePath"];
 
        public Service1()
        {
            InitializeComponent();
 

            Timer timer1 = new Timer();
            timer1.Elapsed += new ElapsedEventHandler(OnElapsedTime);
            timer1.Interval = delay;
            timer1.Enabled = true;
            timer1.Start();
        }
 
        protectedoverridevoid OnStart(string[] args)
        {
            WriteLog("Service started");
 

            if (!Directory.Exists(LogPath))
            {
                Directory.CreateDirectory(LogPath);
            }
 
            try
            {
 
                delay = Int32.Parse(ConfigurationManager.AppSettings["IntervalInSeconds"]) * 1000;
            }
            catch
            {
                WriteLog("IntervalInSeconds key/value incorrect.");
            }
 

            if (delay <5000)
            {
                WriteLog("Sleep time too short: Changed to default(5 secs).");
                delay = 5000;
            }
 
            //Timer timer1 = new Timer();//timer1.Elapsed += new ElapsedEventHandler(OnElapsedTime);//timer1.Interval = delay;//timer1.Enabled = true; 

        }
 
        privatevoid OnElapsedTime(object source, ElapsedEventArgs e)
        {
            write();
            Upload();
        }
      
        privatevoid write() 
        {
 
            string sourcepath = ConfigurationManager.AppSettings["sourcepath"];
            WriteLog("Set source path");
            string[] sourcefiles = Directory.GetFiles(sourcepath);
            WriteLog("Get soutce path file");
 
            foreach (string childfile in sourcefiles)
            {
                WriteLog("Start to find file from loop");
                string sourceFileName = new FileInfo(childfile).Name;
                string destinationPath = ConfigurationManager.AppSettings["destinationPath"];
 
                string destinationFileName = sourceFileName;
                string sourceFile = Path.Combine(sourcepath, sourceFileName);
                WriteLog("Get file from source to destination");
                string destinationFile = Path.Combine(destinationPath, destinationFileName);
                WriteLog("Ready to copy");
                File.Copy(sourceFile, destinationFile, true);
                WriteLog("File copied");
                File.Delete(sourceFile);
                WriteLog("File deleted");
            }
        }
        protectedvoid Upload()
        {
            string excelPath = ConfigurationManager.AppSettings["ExcelPath"];
            DirectoryInfo d = new DirectoryInfo(excelPath);
            FileInfo[] Files = d.GetFiles("*.xls");
 

 
            string str = "";
            WriteLog("ready to enter into loop");
            foreach (FileInfo file in Files)
            {
                str = file.Name;
                string sourceFilePath = ConfigurationManager.AppSettings["SourceFilePath"];
                string SourceFileName = Path.Combine(sourceFilePath, str);
 
                string destinationFilePath = ConfigurationManager.AppSettings["MovePath"];
 
                string destinationFileName = destinationFilePath + str;
 

 

                WriteLog("get file :" + str);
                String strConnection = ConfigurationManager.AppSettings["constr"];
                WriteLog("declare database connection");
                string path = excelPath + str;
 
                // string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 8.0;HDR =YES;Persist Security Info=False";string excelConnectionString = @"Microsoft.Jet.OLEDB.4.0;Data Source=" + path +";Extended Properties=Excel 8.0;HDR =YES;Persist Security Info=False";
                WriteLog("declare excel oledb connection");
                OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
 
                OleDbCommand cmd = new OleDbCommand("Select [ID],[Name] from [Sheet1$]", excelConnection);
 
                    //("Select [Department No],[Department],[Emp No],[Name],[Date],[First],[Last] from [Sheet1$]", excelConnection); 
                excelConnection.Open();
                WriteLog("oledb open");
                OleDbDataReader dReader;
 
                dReader = cmd.ExecuteReader();
 
                SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
 
                sqlBulk.DestinationTableName = "Test1";
                WriteLog("ready to insert into database");
                sqlBulk.WriteToServer(dReader);
                WriteLog("data inserted");
                excelConnection.Close();
                WriteLog("Process completed");
                File.Move(SourceFileName, destinationFileName);
                WriteLog("File moved to bak folder");
                excelConnection.Close();
                cmd.Dispose();
            }
        }
 
       
        protectedoverridevoid OnStop()
        {
            WriteLog("service stopped");
        }
 

        protectedvoid WriteLog(string Msg)
        {
            FileStream fs = new FileStream(LogPath + "\\" + System.DateTime.Today.ToString("yyyyMMdd") + ".log", FileMode.OpenOrCreate, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.BaseStream.Seek(0, SeekOrigin.End);
            sw.WriteLine(System.DateTime.Now.ToString() + ": " + Msg);
            sw.Close();
            sw.Dispose();
            fs.Close();
            fs.Dispose();
        }
    }
}

Repeater Template Desinging

$
0
0
Dear friends Iam new to Asp.net i want to deign one repeater template post based that show me data from databse data may be only text data may be image with text data may be vedio may be only image. so please guide me or give solution

thanks

ASP.NET authorization

$
0
0
Hello,

I want just the administrator can see the admin page.
How can I do this job with ASP.NET authentication and autherization in web.config page?

Saeed

My service move my file Location but doesn't upload the data in sql server... here is my code

$
0
0
<pre>using System;
using System.ServiceProcess;
using System.Data.SqlClient;
using System.IO;
using System.Timers;
using System.Configuration;
using System.Data.OleDb;
using System.Data;
 

 

namespace MoveToDesiredDest
{
    publicpartialclass Service1 : ServiceBase
    {
        long delay = 5000;
        protectedstring LogPath = ConfigurationManager.AppSettings["LogPath"];
        protectedstring MoveFilePathPath = ConfigurationManager.AppSettings["MovePath"];
 
        public Service1()
        {
            InitializeComponent();
 

            Timer timer1 = new Timer();
            timer1.Elapsed += new ElapsedEventHandler(OnElapsedTime);
            timer1.Interval = delay;
            timer1.Enabled = true;
            timer1.Start();
        }
 
        protectedoverridevoid OnStart(string[] args)
        {
            WriteLog("Service started");
 

            if (!Directory.Exists(LogPath))
            {
                Directory.CreateDirectory(LogPath);
            }
 
            try
            {
 
                delay = Int32.Parse(ConfigurationManager.AppSettings["IntervalInSeconds"]) * 1000;
            }
            catch
            {
                WriteLog("IntervalInSeconds key/value incorrect.");
            }
 

            if (delay <5000)
            {
                WriteLog("Sleep time too short: Changed to default(5 secs).");
                delay = 5000;
            }
 
            //Timer timer1 = new Timer();//timer1.Elapsed += new ElapsedEventHandler(OnElapsedTime);//timer1.Interval = delay;//timer1.Enabled = true; 

        }
 
        privatevoid OnElapsedTime(object source, ElapsedEventArgs e)
        {
            write();
            Upload();
        }
      
        privatevoid write() 
        {
 
            string sourcepath = ConfigurationManager.AppSettings["sourcepath"];
            WriteLog("Set source path");
            string[] sourcefiles = Directory.GetFiles(sourcepath);
            WriteLog("Get soutce path file");
 
            foreach (string childfile in sourcefiles)
            {
                WriteLog("Start to find file from loop");
                string sourceFileName = new FileInfo(childfile).Name;
                string destinationPath = ConfigurationManager.AppSettings["destinationPath"];
 
                string destinationFileName = sourceFileName;
                string sourceFile = Path.Combine(sourcepath, sourceFileName);
                WriteLog("Get file from source to destination");
                string destinationFile = Path.Combine(destinationPath, destinationFileName);
                WriteLog("Ready to copy");
                File.Copy(sourceFile, destinationFile, true);
                WriteLog("File copied");
                File.Delete(sourceFile);
                WriteLog("File deleted");
            }
        }
        protectedvoid Upload()
        {
            string excelPath = ConfigurationManager.AppSettings["ExcelPath"];
            DirectoryInfo d = new DirectoryInfo(excelPath);
            FileInfo[] Files = d.GetFiles("*.xls");
 

 
            string str = "";
            WriteLog("ready to enter into loop");
            foreach (FileInfo file in Files)
            {
                str = file.Name;
                string sourceFilePath = ConfigurationManager.AppSettings["SourceFilePath"];
                string SourceFileName = Path.Combine(sourceFilePath, str);
 
                string destinationFilePath = ConfigurationManager.AppSettings["MovePath"];
 
                string destinationFileName = destinationFilePath + str;
 

 

                WriteLog("get file :" + str);
                String strConnection = ConfigurationManager.AppSettings["constr"];
                WriteLog("declare database connection");
                string path = excelPath + str;
 
                // string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 8.0;HDR =YES;Persist Security Info=False";string excelConnectionString = @"Microsoft.Jet.OLEDB.4.0;Data Source=" + path +";Extended Properties=Excel 8.0;HDR =YES;Persist Security Info=False";
                WriteLog("declare excel oledb connection");
                OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
 
                OleDbCommand cmd = new OleDbCommand("Select [ID],[Name] from [Sheet1$]", excelConnection);
 
                    //("Select [Department No],[Department],[Emp No],[Name],[Date],[First],[Last] from [Sheet1$]", excelConnection); 
                excelConnection.Open();
                WriteLog("oledb open");
                OleDbDataReader dReader;
 
                dReader = cmd.ExecuteReader();
 
                SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
 
                sqlBulk.DestinationTableName = "Test1";
                WriteLog("ready to insert into database");
                sqlBulk.WriteToServer(dReader);
                WriteLog("data inserted");
                excelConnection.Close();
                WriteLog("Process completed");
                File.Move(SourceFileName, destinationFileName);
                WriteLog("File moved to bak folder");
                excelConnection.Close();
                cmd.Dispose();
            }
        }
 
       
        protectedoverridevoid OnStop()
        {
            WriteLog("service stopped");
        }
 

        protectedvoid WriteLog(string Msg)
        {
            FileStream fs = new FileStream(LogPath + "\\" + System.DateTime.Today.ToString("yyyyMMdd") + ".log", FileMode.OpenOrCreate, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.BaseStream.Seek(0, SeekOrigin.End);
            sw.WriteLine(System.DateTime.Now.ToString() + ": " + Msg);
            sw.Close();
            sw.Dispose();
            fs.Close();
            fs.Dispose();
        }
    }
}

Need a article on repository and data access code unit testing

$
0
0
googled first but do not find any suitable one. so looking for a details article on repository and data access code in dotnet core unit testing
where we will not use any 3rd part library like mock or effort rather use anything built-in.

anything exist such like ?

can we unit test repository and data access code with intellitrace ? share idea. thanks

Dot Net Core 1.1 Static files(css,fonts,js) are not getting loaded when I am deploying my site in a Sub Domain

$
0
0
Hi,

I created a website in Dot Net Core 1.1.

If I am deploying my site on domain directly all static files are getting loaded and my website is running fine but as I am deploying my website in sub domain, none of the static file(css, fonts, js) is getting loaded.

Really appreciate your help in advance.

Unable to cast object of type 'System.DBNull' to type 'System.String'.

$
0
0
I have this RadioButtonList in Repeater control.

We are using Repeater control dynamically add new rows. I seem to handle projects where rows are dynamically added Smile | :)

In any case, when a record is added for the first time for just one row, there are no issues with this line of code:

<asp:RadioButtonList ID="rdlmhorsepType" Text='<%#string.IsNullOrEmpty((string)Eval("rdlmhorsepType")) ? "Recoil" : Eval("rdlmhorsepType") %>' runat="server" ValidationGroup ="stype" RepeatDirection="Horizontal" TextAlign="Right" style="display:inline;">


However, when one row is filled with data and another row is added, I run into the following error messages:
able to cast object of type 'System.DBNull' to type 'System.String'.

While I am at this, is there a way to populate dynamically populated dropdownlist in Repeater?

I have this:
<asp:DropDownListID="ddlPrevState"cssClass="disabledcss"runat="server"AppendDataBoundItems="True"><asp:ListItemValue=""Selected="True"></asp:ListItem></asp:DropDownList>


Here is C# code:
//I query the db in pageload() event: 
       //We query the DB only once in the Page Load
       con = new SqlConnection(ConfigurationManager.ConnectionStrings["ppmtest"].ToString());
       string sSQL = "Select sID,sName from states ORDER By sName ASC";
       // Response.Write(sSQL);//Response.End();
       SqlCommand cmd3 = new SqlCommand(sSQL, con);
       con.Open();
       cstable = new DataTable();
cstable.Load(cmd3.ExecuteReader());
  
  //Then I call it in ItemDataBound...) eventprotectedvoid repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
      {
          var ddlPState = (DropDownList)e.Item.FindControl("ddlPrevState");
          ddlPState.DataSource = cstable;
          ddlPState.DataTextField = "sName";
          ddlPState.DataValueField = "sID";
        ddlPState.DataBind();


Any ideas how to resolve this?

Thanks as always

Implementation advice for quiz with 4 choice questions

$
0
0
Hey, I', looking for some implementation advice. I am creating this ASP.NET MVC page for quizzes that each course may have a different number of questions with 4 choices. I would like to send the questions to my view as my Model, and by submitting the form, my controller endpoint receives the Id of the questions and selected answers.
Can you please give me some tips that how to send such information to my controller using the sample code I wrote in the following?

Thank you in advance.

My Model

publicclass QuizQuestion
    {
        [Key]
        publicint QuestionId { get; set; }
        publicint CourseId { get; set; }
        publicint Order { get; set; }
        publicstring Question { get; set; }
        publicstring Choice1 { get; set; }
        publicstring Choice2 { get; set; }
        publicstring Choice3 { get; set; }
        publicstring Choice4 { get; set; }
        publicint RightAnswer { get; set; }
    }

My View

using (Html.BeginForm("Submit", "Quiz", FormMethod.Post, new { }))
                        {
                        @Html.AntiForgeryToken()
                        foreach (var item in Model.QuizJustQuestionsDto)
                        {
                        <div class="row">
                            @(item.Order + ". " + item.Question)<br />
                            @Html.RadioButton(item.QuestionId.ToString(), 1) @Html.Label(item.Choice1)<br />
                            @Html.RadioButton(item.QuestionId.ToString(), 2) @Html.Label(item.Choice2)<br />
                            @Html.RadioButton(item.QuestionId.ToString(), 3) @Html.Label(item.Choice3)<br />
                            @Html.RadioButton(item.QuestionId.ToString(), 4) @Html.Label(item.Choice4)
                        </div>
                        }

Any utilities for replicating Web Site files through intermediary drop into web site testing location.

$
0
0
I am working on a .NET Core product representing a web site server. There are HTML, JS, CSHTML, etc. files in the Team Foundation Services repository not necessarily organized in folders the same way they will end up on the system actually hosting the web site.

Is anyone aware of a utility that will take the source files, make a copy to an intermediate location, and then copy from the intermediate location to update the pages and files on the system hosting the web site?

I am changing the source files and want to see the changes reflected on the web site system, which is a VM that must be reached through an intermediate drop location. I can run the utility on the development system and the target system easily enough. It is a PITA to keep track of which files were modified and to keep copying the files by hand.

Just asking ahead of time, so I don't go rewrite the wheel.
I need a 32 bit unsigned value just to hold the number of coding WTF I see in a day …

How do I handle nulls in RadioButtonList in Repeater?

$
0
0
Greetings again.

I have this:

sp:RadioButtonList ID="rdlmhorsepType" Text='<%#Eval("horsepType").ToString()%>' runat="server" ValidationGroup ="stype" RepeatDirection="Horizontal" TextAlign="Right" style="display:inline;"  AutoPostBack="true" OnSelectedIndexChanged="horsepType_SelectedIndexChanged"><asp:ListItem Text="Electric" />
  <asp:ListItem Text="Recoil" />
</asp:RadioButtonList><br />


When a user enters his/her account number, if there is data associated with that account number, it populates a repeater form.

This part works fine.

The issue is that if no data is associated with that account number, I get the following error:

'horsepType' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value

In other words, if RadioButtonList is null, it throws that error.

I have several of those on my Repeater control.

Any ideas how to resolve this?

Thanks a lot in advance

Adding API's to website

$
0
0
Hello All!

Not sure if this is the correct forum to ask this, so if not, please let me know and I will have it changed.

I have created an API for my website that Godaddy hosts on a dedicated server. I have Wordpress installed and it's on a Linux server. I created the API in Visual Studio 2015 Community and ran tests on my local PC and it works as expected. Now, I need to put it online so I can test. I am planning on having it in my WPF desktop program that when the user clicks a button it will call the API and return the result. This API will check a database to see if the license code is there and if not already used. Currently, I have static code that will return a value and not connected to the database yet.

My question: Where on my website do I put files and what files go on the website? Also, how do I find out what the actual URL will be for my button click to call the API?

Thank you in advance

vb.net 2010 web form app point to correct .net framework

$
0
0
I just started to be assigned a work station that was low on memory so I accidently removed the wrong version of the .net framework. To correct the problem, I downloaded .net framework 4.0 since that is what the application uses. This web form application uses vb.net 2010 visual studio ide. 
I problem is I probably downloaded the wrong version. The application probably was using a version number 4.3 I am guessing. 
Thus I am trying to determine what I need to do to solve the problem.
Here is where the steps of where the problem lies:
'retarget the project to .net framework 4.0. After the project opens, you can retarget the
1. When I try to debug the application, I get the following error message:
”Retarget the project to .net framework 4.0.

Once I see the above message, I just click the OK button. I do not know where to point the application.
2. After that point I get lots of messages that look like the following:
AttendanceLetters\App_Code\mylistbox.vb(1): Build (web): Reference assemblies for target .NET Framework version not found; please ensure they are installed, or select a valid target version.
Thus  to solve the problem can you tell me the following:
1. Can you tell me and/or point to a url (link) that will solve the problem tell me how and/or how to point the application to the correct target link?
2. If that is not possible, do I need to download some version of the .net framework that the application is expecting to see? If so, how can I tell what version the application is looking for?
3. If the above solutions do not work. should I uninstall the visual studio 2010 that is on this workstation and reinstall a new version so that the application can find the correct version of the .net framework?
4. If you have a different solution would you tell me what I should do to solve the problem?

Need a article on repository and data access code unit testing

$
0
0
googled first but do not find any suitable one. so looking for a details article on repository and data access code in dotnet core unit testing
where we will not use any 3rd part library like mock or effort rather use anything built-in.

anything exist such like ?

can we unit test repository and data access code with intellitrace ? share idea. thanks

Dot Net Core 1.1 Static files(css,fonts,js) are not getting loaded when I am deploying my site in a Sub Domain

$
0
0
Hi,

I created a website in Dot Net Core 1.1.

If I am deploying my site on domain directly all static files are getting loaded and my website is running fine but as I am deploying my website in sub domain, none of the static file(css, fonts, js) is getting loaded.

Really appreciate your help in advance.

Unable to cast object of type 'System.DBNull' to type 'System.String'.

$
0
0
I have this RadioButtonList in Repeater control.

We are using Repeater control dynamically add new rows. I seem to handle projects where rows are dynamically added Smile | :)

In any case, when a record is added for the first time for just one row, there are no issues with this line of code:

<asp:RadioButtonList ID="rdlmhorsepType" Text='<%#string.IsNullOrEmpty((string)Eval("rdlmhorsepType")) ? "Recoil" : Eval("rdlmhorsepType") %>' runat="server" ValidationGroup ="stype" RepeatDirection="Horizontal" TextAlign="Right" style="display:inline;">


However, when one row is filled with data and another row is added, I run into the following error messages:
able to cast object of type 'System.DBNull' to type 'System.String'.

While I am at this, is there a way to populate dynamically populated dropdownlist in Repeater?

I have this:
<asp:DropDownListID="ddlPrevState"cssClass="disabledcss"runat="server"AppendDataBoundItems="True"><asp:ListItemValue=""Selected="True"></asp:ListItem></asp:DropDownList>


Here is C# code:
//I query the db in pageload() event: 
       //We query the DB only once in the Page Load
       con = new SqlConnection(ConfigurationManager.ConnectionStrings["ppmtest"].ToString());
       string sSQL = "Select sID,sName from states ORDER By sName ASC";
       // Response.Write(sSQL);//Response.End();
       SqlCommand cmd3 = new SqlCommand(sSQL, con);
       con.Open();
       cstable = new DataTable();
cstable.Load(cmd3.ExecuteReader());
  
  //Then I call it in ItemDataBound...) eventprotectedvoid repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
      {
          var ddlPState = (DropDownList)e.Item.FindControl("ddlPrevState");
          ddlPState.DataSource = cstable;
          ddlPState.DataTextField = "sName";
          ddlPState.DataValueField = "sID";
        ddlPState.DataBind();


Any ideas how to resolve this?

Thanks as always
Viewing all 3938 articles
Browse latest View live


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