|
Post by Admin on Feb 9, 2014 21:37:53 GMT
|
|
|
Post by m on Apr 20, 2014 3:29:01 GMT
Helo Michiel! I have a problem with the navigation menu. The dropdown under the 'Reviews' does not work for me. Below is the fragment of the MasterPage.master:
<script type="text/javascript" src="Scripts/jquery-1.3.2.min.js"></script> <script type="text/javascript"> function mainmenu() { $(" #nav ul ").css({ display: "none" }); // Opera Fix
$(" #nav li").hover(function () { $(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(400); } , function () { $(this).find('ul:first').css({ visibility: "hidden" }); }); }
$(document).ready(function () { mainmenu(); }); </script> <link rel="stylesheet" type="text/css" href="Styles/StyleSheet.css" /> </head>
<body> <form id="form1" runat="server"> <div id="wrapper"> <div id="banner"></div>
<div id="navigation"> <ul id="nav"> <li><a href="~/Pages/Home.aspx" runat="server">Home</a></li> <li><a href="#" runat="server">Reviews</a> <ul> <li><a href="Pages/Coffee.aspx" runat="server">Coffee</a></li> <li><a href="#" runat="server">Coffee Shops</a></li> <li><a href="#" runat="server">Coffee brands</a></li> </ul> </li> <li><a href="#" runat="server">Shop</a></li> <li><a href="#" runat="server">About</a></li> <li><a id="a1" href="#" runat="server">Management</a></li> </ul> </div> ... ...
Thank you in advance for help. Cheers! m.
|
|
|
Post by m on Apr 20, 2014 3:34:19 GMT
I just solved the problem by entering the correct path to the link to jquery. Since my question is useless, please delete my previous and present post. (thank you for the tutorial!) Cheers! m.
|
|
aisha
New Member
Posts: 8
|
Post by aisha on May 4, 2014 18:08:00 GMT
Thanks ALot for the tutorials I benefited a lot from them really
I made a website exatly like your cofee site but with other information I made till video 3
I have a problem whe I open my site to the CMS ( Add to tables ) page and I upload image and add data to all cells the label always give me the message ( Upload Failed) I dont know why!
|
|
m
New Member
Posts: 9
|
Post by m on May 4, 2014 18:44:51 GMT
Thanks ALot for the tutorials I benefited a lot from them really I made a website exatly like your cofee site but with other information I made till video 3 I have a problem whe I open my site to the CMS ( Add to tables ) page and I upload image and add data to all cells the label always give me the message ( Upload Failed) I dont know why! Can you post Coffee.cs, ConnectionClass.cs, Coffee_Add.aspx, Coffee_Add.cs ?
|
|
aisha
New Member
Posts: 8
|
Post by aisha on May 4, 2014 19:06:22 GMT
ok I made a website exactly the same but about manuscripts
thisis Manu.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web;
public class Manu { public int w_id { get; set; } public string w_type { get; set; } public string w_shape { get; set; } public string w_imageTras { get; set; } public string waqif_name { get; set; } public string w_place { get; set; } public int w_date { get; set; } public string w_image { get; set; } public int m_id { get; set; }
public Manu(int w_id, string w_type, string w_shape, string w_imageTras, string waqif_name, string w_place, int w_date, string w_image, int m_id) { this.w_id = w_id; this.w_type = w_type; this.w_shape = w_shape; this.w_imageTras = w_imageTras; this.waqif_name = waqif_name; this.w_place = w_place; this.w_date = w_date; this.w_image = w_image; this.m_id = m_id;
} }
and this is connectionclass
using System; using System.Collections; using System.Configuration; using System.Data.SqlClient;
public static class ConnectionClass { private static SqlConnection conn; private static SqlCommand command;
static ConnectionClass() { string connectionString = ConfigurationManager.ConnectionStrings["manuConnection"].ToString(); conn = new SqlConnection(connectionString); command = new SqlCommand("", conn); }
public static ArrayList GetWaqfByType(string waqfType) { ArrayList list = new ArrayList(); string query = string.Format("SELECT * FROM waqf WHERE w_type LIKE '{0}'", waqfType);
try { conn.Open(); command.CommandText = query; SqlDataReader reader = command.ExecuteReader();
while (reader.Read()) { int w_id = reader.GetInt32(0); string w_type = reader.GetString(1); string w_shape = reader.GetString(2); string w_imageTras = reader.GetString(3); string waqif_name = reader.GetString(4); string w_place = reader.GetString(5); int w_date = reader.GetInt32(6); string w_image = reader.GetString(7); int m_id = reader.GetInt32(8);
Manu manu = new Manu(w_id, w_type, w_shape, w_imageTras, waqif_name, w_place, w_date, w_image, m_id); list.Add(manu); } } finally { conn.Close(); } return list; }
public static ArrayList GetManuscriptByID(string manuscriptID) { ArrayList list = new ArrayList(); string query = string.Format("SELECT * FROM manuscript WHERE m_ID LIKE '{0}'", manuscriptID);
try { conn.Open(); command.CommandText = query; SqlDataReader reader = command.ExecuteReader();
while (reader.Read()) { int m_id = reader.GetInt32(0); string m_place = reader.GetString(1); string m_number = reader.GetString(2); string m_title = reader.GetString(3); string m_author = reader.GetString(4); string m_date = reader.GetString(5); string m_otherDates = reader.GetString(6);
Manuscript manuscript = new Manuscript(m_id, m_place, m_number, m_title, m_author, m_date, m_otherDates); list.Add(manuscript); } } finally { conn.Close(); } return list; }
public static void AddWaqf(Manu manu) { string query = string.Format( "INSERT INTO manu VALUES({0},'{1}','{2}','{3}','{4}','{5}',{6},'{7}',{8})", manu.w_id,manu.w_type,manu.w_shape,manu.w_imageTras,manu.waqif_name,manu.w_place,manu.w_date,manu.w_image,manu.m_id); command.CommandText = query; try { conn.Open(); command.ExecuteNonQuery(); } finally { conn.Close(); command.Parameters.Clear(); } } }
this is waqf_add.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageCMS.master" AutoEventWireup="true" CodeFile="Waqf_Add.aspx.cs" Inherits="Waqf_Add" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <h3>Add new Waqf:</h3> <table cellspacing="15" class="waqfTable"> <tr> <td style="width: 100px">
w_id</td> <td>
<asp:TextBox ID="txt_w_id" runat="server" Width="300px"></asp:TextBox>
</td> </tr>
<tr> <td style="width: 100px">
w_type</td> <td>
<asp:TextBox ID="txt_w_type" runat="server" Width="300px"></asp:TextBox>
</td> </tr>
<tr> <td style="width: 100px">
w_shape</td> <td>
<asp:TextBox ID="txt_w_shape" runat="server" Width="300px"></asp:TextBox>
</td> </tr>
<tr> <td style="width: 100px">
w_imageTras</td> <td>
<asp:TextBox ID="txt_w_imageTras" runat="server" Width="300px" Height="60px" TextMode="MultiLine"></asp:TextBox>
</td> </tr>
<tr> <td style="width: 100px; height: 37px;">
waqif_name</td> <td style="height: 37px">
<asp:TextBox ID="txt_waqif_name" runat="server" Width="300px"></asp:TextBox>
</td> </tr>
<tr> <td style="width: 100px; height: 19px">
w_place</td> <td style="height: 19px">
<asp:TextBox ID="txt_w_place" runat="server" Width="300px"></asp:TextBox>
</td> </tr>
<tr> <td style="width: 100px">
w_date</td> <td>
<asp:TextBox ID="txt_w_date" runat="server" style="margin-bottom: 0px" Width="300px"></asp:TextBox>
</td> </tr>
<tr> <td style="width: 100px">
w_image</td> <td>
<asp:DropDownList ID="ddlImage" runat="server" Width="300px"> </asp:DropDownList> <br /> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="btnUploadImage" runat="server" Text="Upload Image" OnClick="btnUploadImage_Click" />
</td> </tr>
<tr> <td style="width: 100px; height: 23px">
m_id</td> <td style="height: 23px" width="300">
<asp:TextBox ID="txt_m_id" runat="server" Width="300px"></asp:TextBox>
</td> </tr>
</table> <asp:Label ID="lblResult" runat="server" Text=""></asp:Label> <br /> <asp:Button ID="btnSave1" runat="server" Text="Save" OnClick="btnSave1_Click" />
</asp:Content>
this is waqf_add.cs
using System; using System.Collections; using System.IO;
public partial class Waqf_Add : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string selectedValue = ddlImage.SelectedValue; ShowImages(); ddlImage.SelectedValue = selectedValue; }
private void ShowImages() { //Get all filepaths string[] images = Directory.GetFiles(Server.MapPath("Images/")); //Get all filenames and add them to an arraylist
ArrayList imageList = new ArrayList();
foreach(string image in images) { string imageName = image.Substring(image.LastIndexOf(@"\")+ 1); imageList.Add(imageName); } //Set the arrayList as the dropdownview's datasource and refresh ddlImage.DataSource = imageList; ddlImage.DataBind(); } private void ClearTextFields() { txt_w_id.Text = ""; txt_w_type.Text = ""; txt_w_shape.Text = ""; txt_w_imageTras.Text = ""; txt_waqif_name.Text = ""; txt_w_place.Text = ""; txt_w_date.Text = ""; txt_m_id.Text = "";
}
protected void btnUploadImage_Click(object sender, EventArgs e) { try { string filename = Path.GetFileName(FileUpload1.FileName); FileUpload1.SaveAs(Server.MapPath("Images/")+filename); lblResult.Text = "Image " + filename + " succesfully uploaded!"; Page_Load(sender, e); } catch(Exception) { lblResult.Text = "Upload failed!"; } } protected void btnSave1_Click(object sender, EventArgs e) { try { int w_id = Convert.ToInt32(txt_w_id); string w_type = txt_w_type.Text; string w_shape = txt_w_shape.Text; string w_imageTras = txt_w_imageTras.Text; string waqif_name = txt_waqif_name.Text; string w_place = txt_w_place.Text; int w_date = Convert.ToInt32(txt_w_date); string w_image = "Images/"+ddlImage.SelectedValue; int m_id = Convert.ToInt32(txt_m_id);
Manu manu = new Manu(w_id,w_type,w_shape,w_imageTras,waqif_name,w_place,w_date,w_image,m_id); ConnectionClass.AddWaqf(manu); lblResult.Text = "Upload Succesfull!"; ClearTextFields(); } catch { lblResult.Text = "Upload Failed!"; } } }
thank u for helping
|
|
m
New Member
Posts: 9
|
Post by m on May 4, 2014 19:32:00 GMT
In ConnectionClass AddWaqf() query surround {0} and {8} with apostrophes like the following:
string query = string.Format( "INSERT INTO manu VALUES('{0}','{1}','{2}','{3}','{4}','{5}',{6},'{7}','{8}')", manu.w_id,manu.w_type,manu.w_shape,manu.w_imageTras,manu.waqif_name,manu.w_place,manu.w_date,manu.w_image,manu.m_id);
I hope this helps
|
|
aisha
New Member
Posts: 8
|
Post by aisha on May 4, 2014 19:39:43 GMT
In ConnectionClass AddWaqf() query surround {0} and {8} with apostrophes like the following: string query = string.Format( "INSERT INTO manu VALUES('{0}','{1}','{2}','{3}','{4}','{5}',{6},'{7}','{8}')", manu.w_id,manu.w_type,manu.w_shape,manu.w_imageTras,manu.waqif_name,manu.w_place,manu.w_date,manu.w_image,manu.m_id); I hope this helps ok I put them but still not adding the data
|
|
aisha
New Member
Posts: 8
|
Post by aisha on May 4, 2014 19:43:27 GMT
In ConnectionClass AddWaqf() query surround {0} and {8} with apostrophes like the following: string query = string.Format( "INSERT INTO manu VALUES('{0}','{1}','{2}','{3}','{4}','{5}',{6},'{7}','{8}')", manu.w_id,manu.w_type,manu.w_shape,manu.w_imageTras,manu.waqif_name,manu.w_place,manu.w_date,manu.w_image,manu.m_id); I hope this helps also I forgot to put @ before insert and i put it but also does not work
|
|
m
New Member
Posts: 9
|
Post by m on May 4, 2014 19:46:25 GMT
Also you can try to change the image save path within waqf_add.cs btnUploadImage_Click() from "Images/" to "/Images/" Adding a slash before should do the job.
FileUpload1.SaveAs(Server.MapPath("/Images/")+filename);
and
string w_image = "/Images/"+ddlImage.SelectedValue;
|
|
aisha
New Member
Posts: 8
|
Post by aisha on May 4, 2014 20:01:12 GMT
Also you can try to change the image save path within waqf_add.cs btnUploadImage_Click() from "Images/" to "/Images/" Adding a slash before should do the job. FileUpload1.SaveAs(Server.MapPath("/Images/")+filename); and string w_image = "/Images/"+ddlImage.SelectedValue; I did now unfortunately no || sorry for disturbig
|
|
|
Post by Admin on May 5, 2014 13:47:35 GMT
Hi Aisha
I think I found the solutions to your "upload failed" errors
I found these errors: Some properties referred to a textbox itself instead of the text in the textbox.
For example: Waqf_Add.aspx Line 63 int w_id = Convert.ToInt32(txt_w_id); needs to be int w_id = Convert.ToInt32(txt_w_id.Text);
And your query was referring to the wrong table E.g: Connectionclass Line 89 INSERT INTO manu VALUES({0}... needs to be INSERT INTO waqf VALUES({0}...
I have sent the updated project to your e-mail.
Hope that helps!
|
|
|
Post by godsavecanada on May 13, 2014 22:04:36 GMT
Hi Michiel, I am busy with video Part3 CMS. I noticed that my Coffee_Add.aspx and Coffee_Overview.aspx do not have code behind files. Did I do something wrong?
|
|
|
Post by Raam on May 22, 2014 9:23:31 GMT
Hi Michiel,
these are the warnings and errors am getting while running it.
Warning 1 The 'targetFramework' attribute is not declared. C:\Users\Ramachandran.selvara\Documents\IS\OnlineAssesment\reference\Source\Asp.Net Part 6 Full\CoffeeWebsite-Shop\web.config 24 31 C:\...\OnlineAssesment\
Warning 2 The 'controlRenderingCompatibilityVersion' attribute is not declared. C:\Users\Ramachandran.selvara\Documents\IS\OnlineAssesment\reference\Source\Asp.Net Part 6 Full\CoffeeWebsite-Shop\web.config 49 12 C:\...\OnlineAssesment\
Warning 3 The 'clientIDMode' attribute is not declared. C:\Users\Ramachandran.selvara\Documents\IS\OnlineAssesment\reference\Source\Asp.Net Part 6 Full\CoffeeWebsite-Shop\web.config 49 55 C:\...\OnlineAssesment\
Error 4 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. C:\Users\Ramachandran.selvara\Documents\IS\OnlineAssesment\reference\Source\Asp.Net Part 6 Full\CoffeeWebsite-Shop\web.config 36
|
|
|
Post by asraa on Jul 20, 2014 11:12:29 GMT
when i upload picture it is successful and is added in my images folder and when i hit save button that is also successful but no data is added in my database can you tell me what i am doing wrong? no errors in all this is same code you use code_Add.aspx <!-----------------------------------------> using System; using System.IO; using System.Collections; using System.Text;
public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string selectedValue = ddlImage.SelectedValue; ShowImages(); ddlImage.SelectedValue = selectedValue;
} private void ShowImages() { //get files string[] images = Directory.GetFiles(Server.MapPath("~/Images/Coffee")); // get file names ArrayList imageList = new ArrayList(); foreach (string image in images) { string imageName = image.Substring(image.LastIndexOf(@"\") + 1); imageList.Add(imageName); } //Set aray list as dropdown view data source and refresh ddlImage.DataSource = imageList; ddlImage.DataBind();
} private void ClearTextFields() {
txtCountry.Text = ""; txtName.Text = ""; txtPrice.Text = ""; txtReview.Text = ""; txtRoast.Text = ""; txtType.Text = "";
}
protected void btnUploadImage_Click(object sender, EventArgs e) { try { string filename = Path.GetFileName(FileUpload1.FileName); FileUpload1.SaveAs(Server.MapPath("~/Images/Coffee/") + filename); lblResults.Text = " Image " + filename + " Sucessfully uploaded!"; Page_Load(sender, e); } catch { lblResults.Text = "Upload failed!"; } } protected void btnSave_Click(object sender, EventArgs e) { try { string name = txtName.Text; string type = txtType.Text; double price = Convert.ToDouble(txtPrice.Text); price = price / 100; string roast = txtRoast.Text; string country = txtCountry.Text; string image = " Images/Coffee/" + ddlImage.SelectedValue; string review = txtReview.Text;
Coffee coffee = new Coffee(name, type, price, roast, country, image, review); ConnectionClass.AddCoffee(coffee); lblResults.Text = "upload sucessfull!"; ClearTextFields();
} catch { lblResults.Text = "Upload failed!"; } } } <!-------------------------------------> connection class
using System.Collections; using System.Configuration; using System.Data.SqlClient;
public static class ConnectionClass { private static SqlConnection conn; private static SqlCommand command;
static ConnectionClass() { string connectionString = ConfigurationManager.ConnectionStrings["coffeeDBConnectionString"].ToString(); conn = new SqlConnection(connectionString); command = new SqlCommand("", conn); }
public static ArrayList GetCoffeeByType(string coffeeType) { ArrayList list = new ArrayList(); string query = string.Format("SELECT * FROM coffee WHERE type LIKE '{0}'", coffeeType);
try { conn.Open(); command.CommandText = query; SqlDataReader reader = command.ExecuteReader();
while (reader.Read()) { int id = reader.GetInt32(0); string name = reader.GetString(1); string type = reader.GetString(2); double price = reader.GetDouble(3); string roast = reader.GetString(4); string country = reader.GetString(5); string image = reader.GetString(6); string review = reader.GetString(7);
Coffee coffee = new Coffee(id, name, type, price, roast, country, image, review); list.Add(coffee); } } finally { conn.Close(); }
return list; } public static void AddCoffee(Coffee coffee) { string query = string.Format( "INSERT INTO coffee VALUES ('{0}','{1}', @price, '{2}','{3}', '{4}', '{5}')", coffee.Name, coffee.Type,coffee.Roast, coffee.Country, coffee.Image, coffee.Review); command.Parameters.Add(new SqlParameter("@price", coffee.Price)); try{ conn.Open(); command.ExecuteNonQuery(); } finally{
conn.Close(); command.Parameters.Clear(); }
} }
|
|