'Compiler Error Message: CS0246: The type or namespace name 'Slider' could not be found
i have created image insert page form using ASP.NET and C# and getting error while running on my hosting server it shows below error , but it works fine on localhost.
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Slider' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 12: public partial class AddImage : System.Web.UI.Page Line 13: { Line 14: Slider sliderinsrt = new Slider(); Line 15: protected void Page_Load(object sender, EventArgs e) Line 16: {
i am posting code of insert image here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Data.SqlClient;
//using System.Controls;
public partial class AddImage : System.Web.UI.Page
{
Slider sliderinsrt = new Slider();
protected void Page_Load(object sender, EventArgs e)
{
Label5.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
sliderinsrt.Title = TextBox1.Text;
sliderinsrt.Description = TextBox2.Text;
sliderinsrt.ImageName = FileUpload1.PostedFile.FileName;
SaveImage();
int mode=0;
string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(conn);
con.Open();
SqlCommand cmd = new SqlCommand("InsertImage", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Id", sliderinsrt.ID);
cmd.Parameters.AddWithValue("@Title", sliderinsrt.Title);
cmd.Parameters.AddWithValue("@Description", sliderinsrt.Description);
cmd.Parameters.AddWithValue("@ImageName", sliderinsrt.ImageName);
cmd.Parameters.AddWithValue("@mode", mode);
cmd.ExecuteNonQuery();
Label5.Visible = true;
Label5.Text = "Successfully Saved";
con.Close();
TextBox1.Text="";
TextBox2.Text="";
}
private void SaveImage()
{
string message = string.Empty;
if (FileUpload1.HasFile)
{
string ext = System.IO.Path.GetExtension(this.FileUpload1.PostedFile.FileName);
ext = ext.ToLower();
if (ext == ".gif" || ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp")
{
string fileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
Session["fileName"] = fileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/UploadSliderImage/" + fileName).Replace("\\", "//"));
}
else
{
message = "Invalid File Format";
}
}
}
}
Solution 1:[1]
For people that receive this error and is working with Xamarin Forms, is missing this:
using Xamarin.Forms;
Solution 2:[2]
For anyone else searching this:
using UnityEngine.UI;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Led Machine |
Solution 2 | lew |