Kaizub, why wouldn't you want help from the public forum so that your experiences may help others with similar problems? Can you explain to us what you mean by having trouble finishing? What aren't you able to do? Please be descriptive as this helps us all
help you better.
That's because those are some small things, probably easy to repair and I don't think there is a point to post each thing in new thread or something. Anyhow I recently posted an issue and I still haven't got an answer so I thought it would be better if someone
could help me individually or finish it for me...
1. The problem I still struggle with is:
http://forums.asp.net/t/1768655.aspx/1/10?User+who+added+the+data+deletes+and+edits+it
2. I have some forms on my website and not all of the fields are required to fill in and what I would like to do is to fill them in automatically. So even if user will not put anything in, it will show something like 'not specified' or 'not known'.
3. Where I have the forms to update some fields in the database, it updates everyone. Whereas I would like to update only those which were filled by the user so I don't end up with empty fields.
4. I have tried to add paging to those two pages below but I've failed. I think it has something to do with UrlData.
@{
Layout = "~/Shared/_SiteLayout.cshtml";
var db = Database.Open("StarterSite");
var category = UrlData[0];
Page.Title = "Posted jobs in category: " + category;
<h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
var data = db.Query("SELECT * FROM PostedJobs WHERE Category = @0", category);
foreach (var row in data)
{
<div id="postedjobs">
<ul>
<li>
<h3><a href="/Job/@row.JobID">@row.JobTitle</a></h3>
<p><b>Posted:</b> @row.PostedDate</p>
<p><b>Location:</b> @row.Location</p>
<p><b>Details:</b><br />@row.JobDescription</p>
<p><b>By: @row.UserId</b></p>
</li>
</ul>
</div>
}
}
@{
Layout = "~/Shared/_SiteLayout.cshtml";
Page.Title = "Search Results";
var db = Database.Open("StarterSite");
var query = "SELECT * FROM PostedJobs WHERE JobDescription LIKE @0 AND Location = @1";
var jobDescription = "%" + Request["jobDescription"] + "%";
var location = Request["location"];
var data = db.Query(query, jobDescription, location);
foreach(var row in data)
{
<div id="postedjobs">
<ul>
<li>
<h3><a href="/Jobs/@row.JobID">@row.JobTitle</a></h3>
<p><b>Posted:</b> @row.PostedDate</p>
<p><b>Category:</b> @row.Category <b>Location:</b> @row.Location</p>
<p><b>Details:</b><br />@row.JobDescription</p>
<p><b>By: @row.UserId</b></p>
</li>
</ul>
</div>
}
}
5. What about the one just above, I am wondering how can I specify if there is no search results.
6. I also can't figure out why in code posted below the errors don't work, because everywhere else where I have similar codes they do.
var isValid = true;
var comment = "";
var star1 = "";
var star2 = "";
var star3 = "";
var posted = DateTime.Now;
var byUser = WebSecurity.CurrentUserId;
var commentErrorMessage = "";
if(IsPost) {
comment = Request.Form["comment"];
star1 = Request.Form["star1"];
star2 = Request.Form["star2"];
star3 = Request.Form["star3"];
if (comment.IsEmpty()) {
commentErrorMessage = "You must specify your comment.";
isValid = false;
}
else if (comment.Length > 4000) {
commentErrorMessage = "Only 4000 characters are allowed.";
isValid = false;
}
if (isValid) {
db.Execute("INSERT INTO FeedbackLeft (TradesmanId, Comment, Quality, Punctuality, Communication, Posted, ByUser) VALUES (@0, @1, @2, @3, @4, @5, @6)", tradesmanId, comment, star1, star2, star3, posted, byUser);
Response.Redirect("/Tradesman/" + tradesmanId);
}
}
else {
if (!isValid) {
<p class="message error">Please correct the errors and try again.</p>
}
<form method="post" action="">
<fieldset>
<legend><h3>Feedback Form</h3></legend>
<ol>
<li class="comment">
<label for="comment"><p>Your comment:</p></label>
<textarea rows="6" cols="35" id="comment" name="comment" title="Your comment" value="@comment" @if(!commentErrorMessage.IsEmpty()){<text>class="error-field"</text>}></textarea>
<p>(Only 4000 characters allowed)</p>
@if (!commentErrorMessage.IsEmpty()) {
<label for="comment" class="validation-error">@commentErrorMessage</label>
}
</li>
<br />
Well that's all for now. If I could get at least one resolved, it would bring back my hope for finishing that website.
1. The problem I still struggle with is:
http://forums.asp.net/t/1768655.aspx/1/10?User+who+added+the+data+deletes+and+edits+it
With this, what do your tables look like???
Kaizub
2. I have some forms on my website and not all of the fields are required to fill in and what I would like to do is to fill them in automatically. So even if user will not put anything in, it will show something like 'not specified' or 'not known'.
For that, you can put the field in as a default value so that way if nothing is entered the default value you specify stands.
Kaizub
3. Where I have the forms to update some fields in the database, it updates everyone. Whereas I would like to update only those which were filled by the user so I don't end up with empty fields.
Ok, what you'll want to do is in your database look for the userid that entered those entries and in your query, specify that you only update the ones that belong to that user. Post your table design and query if you need help with it.
As far as #4, I'll have to get back to you on that. Then again, someone else may step into this here. My best guess at this point would be change:
<h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
to:
<h3>Change to <a href="../Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
I think I clearly specified everything in the other thread. If not, tell me exactly what you'd like to see.
bbcompent1
Ok, what you'll want to do is in your database look for the userid that entered those entries and in your query, specify that you only update the ones that belong to that user. Post your table design and query if you need help with it.
I don't think you understood or maybe I explained it wrong. I have the user specified. What goes wrong is for example I have name, address and town, and let's say the user wants to change only the town but if he left the name and address blank when updating,
it deletes that data form the database, and there is no more name and address specified.
bbcompent1
My best guess at this point would be change:
<h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
to:
<h3>Change to <a href="../Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
or put the full opening URL in where the .. is
And again the problem is not there but in paging. What I'd like to do is have only 10 results. That's how I tried to do it, but it doesn't work:
@{
Layout = "~/Shared/_SiteLayout.cshtml";
var db = Database.Open("StarterSite");
var category = UrlData[0];
Page.Title = "Posted jobs in category: " + category;
var pageSize = 3;
var totalPages = 0;
var count = 0;
var page = UrlData[1].IsInt() ? UrlData[1].AsInt() : 1;
var offset = (page -1) * pageSize;
var sql = "Select Count(*) From PostedJobs";
count = (int)db.QueryValue(sql);
totalPages = count/pageSize;
if(count % pageSize > 0){
totalPages += 1;
}
sql = "SELECT * FROM PostedJobs WHERE Category = @0" +
"Order By PostedDate OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY;";
var data = db.Query(sql, offset, pageSize, category);
<h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
foreach (var row in data)
{
<div id="postedjobs">
<ul>
<li>
<h3><a href="/Job/@row.JobID">@row.JobTitle</a></h3>
<p><b>Posted:</b> @row.PostedDate</p>
<p><b>Location:</b> @row.Location</p>
<p><b>Details:</b><br />@row.JobDescription</p>
<p><b>By: @row.UserId</b></p>
</li>
</ul>
</div>
}
<div> <p>Page @page of @totalPages
<center>
@for (var i = 1; i < totalPages + 1; i++){
<a href="/Categories/Jobs/@category/Page/@i">@i</a>
}
</center></p></div>
}
Kaizub
Member
77 Points
42 Posts
Finishing off the website
Feb 21, 2012 02:17 PM|LINK
I am having trouble with finishing off the website. If there is anyone interested in help or doing so, please contact me by private message.
Thanks
bbcompent1
All-Star
32982 Points
8508 Posts
Moderator
Re: Finishing off the website
Feb 21, 2012 07:18 PM|LINK
Kaizub, why wouldn't you want help from the public forum so that your experiences may help others with similar problems? Can you explain to us what you mean by having trouble finishing? What aren't you able to do? Please be descriptive as this helps us all help you better.
Kaizub
Member
77 Points
42 Posts
Re: Finishing off the website
Feb 22, 2012 04:36 PM|LINK
That's because those are some small things, probably easy to repair and I don't think there is a point to post each thing in new thread or something. Anyhow I recently posted an issue and I still haven't got an answer so I thought it would be better if someone could help me individually or finish it for me...
bbcompent1
All-Star
32982 Points
8508 Posts
Moderator
Re: Finishing off the website
Feb 22, 2012 04:41 PM|LINK
No need to post a new thread each time, just post your questions/issues on this thread and we can try to help you.
Kaizub
Member
77 Points
42 Posts
Re: Finishing off the website
Feb 22, 2012 06:24 PM|LINK
Okay then.
1. The problem I still struggle with is:
http://forums.asp.net/t/1768655.aspx/1/10?User+who+added+the+data+deletes+and+edits+it
2. I have some forms on my website and not all of the fields are required to fill in and what I would like to do is to fill them in automatically. So even if user will not put anything in, it will show something like 'not specified' or 'not known'.
3. Where I have the forms to update some fields in the database, it updates everyone. Whereas I would like to update only those which were filled by the user so I don't end up with empty fields.
4. I have tried to add paging to those two pages below but I've failed. I think it has something to do with UrlData.
@{ Layout = "~/Shared/_SiteLayout.cshtml"; var db = Database.Open("StarterSite"); var category = UrlData[0]; Page.Title = "Posted jobs in category: " + category; <h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3> var data = db.Query("SELECT * FROM PostedJobs WHERE Category = @0", category); foreach (var row in data) { <div id="postedjobs"> <ul> <li> <h3><a href="/Job/@row.JobID">@row.JobTitle</a></h3> <p><b>Posted:</b> @row.PostedDate</p> <p><b>Location:</b> @row.Location</p> <p><b>Details:</b><br />@row.JobDescription</p> <p><b>By: @row.UserId</b></p> </li> </ul> </div> } }@{ Layout = "~/Shared/_SiteLayout.cshtml"; Page.Title = "Search Results"; var db = Database.Open("StarterSite"); var query = "SELECT * FROM PostedJobs WHERE JobDescription LIKE @0 AND Location = @1"; var jobDescription = "%" + Request["jobDescription"] + "%"; var location = Request["location"]; var data = db.Query(query, jobDescription, location); foreach(var row in data) { <div id="postedjobs"> <ul> <li> <h3><a href="/Jobs/@row.JobID">@row.JobTitle</a></h3> <p><b>Posted:</b> @row.PostedDate</p> <p><b>Category:</b> @row.Category <b>Location:</b> @row.Location</p> <p><b>Details:</b><br />@row.JobDescription</p> <p><b>By: @row.UserId</b></p> </li> </ul> </div> } }5. What about the one just above, I am wondering how can I specify if there is no search results.
6. I also can't figure out why in code posted below the errors don't work, because everywhere else where I have similar codes they do.
var isValid = true; var comment = ""; var star1 = ""; var star2 = ""; var star3 = ""; var posted = DateTime.Now; var byUser = WebSecurity.CurrentUserId; var commentErrorMessage = ""; if(IsPost) { comment = Request.Form["comment"]; star1 = Request.Form["star1"]; star2 = Request.Form["star2"]; star3 = Request.Form["star3"]; if (comment.IsEmpty()) { commentErrorMessage = "You must specify your comment."; isValid = false; } else if (comment.Length > 4000) { commentErrorMessage = "Only 4000 characters are allowed."; isValid = false; } if (isValid) { db.Execute("INSERT INTO FeedbackLeft (TradesmanId, Comment, Quality, Punctuality, Communication, Posted, ByUser) VALUES (@0, @1, @2, @3, @4, @5, @6)", tradesmanId, comment, star1, star2, star3, posted, byUser); Response.Redirect("/Tradesman/" + tradesmanId); } } else { if (!isValid) { <p class="message error">Please correct the errors and try again.</p> } <form method="post" action=""> <fieldset> <legend><h3>Feedback Form</h3></legend> <ol> <li class="comment"> <label for="comment"><p>Your comment:</p></label> <textarea rows="6" cols="35" id="comment" name="comment" title="Your comment" value="@comment" @if(!commentErrorMessage.IsEmpty()){<text>class="error-field"</text>}></textarea> <p>(Only 4000 characters allowed)</p> @if (!commentErrorMessage.IsEmpty()) { <label for="comment" class="validation-error">@commentErrorMessage</label> } </li> <br />Well that's all for now. If I could get at least one resolved, it would bring back my hope for finishing that website.
Thank you
bbcompent1
All-Star
32982 Points
8508 Posts
Moderator
Re: Finishing off the website
Feb 23, 2012 10:59 AM|LINK
With this, what do your tables look like???
For that, you can put the field in as a default value so that way if nothing is entered the default value you specify stands.
Ok, what you'll want to do is in your database look for the userid that entered those entries and in your query, specify that you only update the ones that belong to that user. Post your table design and query if you need help with it.
As far as #4, I'll have to get back to you on that. Then again, someone else may step into this here. My best guess at this point would be change:
<h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
to:
<h3>Change to <a href="../Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
or put the full opening URL in where the .. is
Kaizub
Member
77 Points
42 Posts
Re: Finishing off the website
Feb 26, 2012 01:20 PM|LINK
I think I clearly specified everything in the other thread. If not, tell me exactly what you'd like to see.
I don't think you understood or maybe I explained it wrong. I have the user specified. What goes wrong is for example I have name, address and town, and let's say the user wants to change only the town but if he left the name and address blank when updating, it deletes that data form the database, and there is no more name and address specified.
And again the problem is not there but in paging. What I'd like to do is have only 10 results. That's how I tried to do it, but it doesn't work:
@{ Layout = "~/Shared/_SiteLayout.cshtml"; var db = Database.Open("StarterSite"); var category = UrlData[0]; Page.Title = "Posted jobs in category: " + category; var pageSize = 3; var totalPages = 0; var count = 0; var page = UrlData[1].IsInt() ? UrlData[1].AsInt() : 1; var offset = (page -1) * pageSize; var sql = "Select Count(*) From PostedJobs"; count = (int)db.QueryValue(sql); totalPages = count/pageSize; if(count % pageSize > 0){ totalPages += 1; } sql = "SELECT * FROM PostedJobs WHERE Category = @0" + "Order By PostedDate OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY;"; var data = db.Query(sql, offset, pageSize, category); <h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3> foreach (var row in data) { <div id="postedjobs"> <ul> <li> <h3><a href="/Job/@row.JobID">@row.JobTitle</a></h3> <p><b>Posted:</b> @row.PostedDate</p> <p><b>Location:</b> @row.Location</p> <p><b>Details:</b><br />@row.JobDescription</p> <p><b>By: @row.UserId</b></p> </li> </ul> </div> } <div> <p>Page @page of @totalPages <center> @for (var i = 1; i < totalPages + 1; i++){ <a href="/Categories/Jobs/@category/Page/@i">@i</a> } </center></p></div> }But thanks for number 2 which I resolved :)