|
Hi,
Thanks for your time responding to my question.
My design idea was based on the fact that this is a many to many relationship between teacher and course.
A teacher can teach more than one courses just as a course can be thought by more than one teacher.
This made it many to many. So, there is one way I know to bridge them and that's by creating a third table that has foreign key for both tables.
How would you have designed them?
|
|
|
|
|
I think you have it backwards, and should try flipping them around.
Set the teacher id, then set the course id
If you change the course id first, then the teacher id will not change because you changed the course id, and your using the same parameter @courseid which is static or the same value.
As far as design goes, I'd have to see the map, or see the whole picture to tell. Jorgen is really good at that, you would have to prepare a well worded question in database forum for that.
I think it's a SQL or database issue here.
|
|
|
|
|
Just my opinion, I'm not the best at this.
I think a course is a course, like a shoe being sold online.
You can have the same course, like shoe sizes,
The teacher is just a category, or a shoe size, and the time and day of the course is like the color of a shoe.
So take a course marketing 101,
marketing101-time-teacher
1 table
1 record marketing 101 with time and teacher id
Join 1 more table time represented by time id
Join 1 more table teacher represented by teacher id
Then just update the marketing 101 with the correct time and teacher.
|
|
|
|
|
I want to insert some JavaScript code for validation. Here it is :
script language="javascript">
function checkEmail() {
var email = document.getElementById('txtEmail');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
}</script>
and the code in body is :
<input type='text' id='txtEmail'/>
<input type='submit' name='submit' onclick='Javascript:checkEmail();'/>
Now I want to check for validation on submit button but I also want to run code written in .cs page for
<asp:Button ID="BtnSubmit" runat="server" onclick="Button1_Click" Text="Register Now" />
|
|
|
|
|
Hi,
Something like this should do it:
<asp:Button ID="BtnSubmit" runat="server" onClientClick="return checkEmail();" onClick="Button1_Click" Text="Register Now" />
If your checkEmail routine returns true, then a post back occurs - which will run the serverside code in Button1_Click.
If the validation fails, then no postback will occur.
Hope it helps.
|
|
|
|
|
Dear readers,
Could anyone provide me an example how I can call multiple OData services from within a .net API asynchronously? I’m using DataServiceQuery’s to get all the data from the external OData services. I have tried using:
public static class QueryExtension
{
public static Task<IEnumerable<TResult>>; QueryAsync<TResult>(this DataServiceQuery<TResult> query)
{
return Task<IEnumerable<TResult>>.Factory.FromAsync(query.BeginExecute, query.EndExecute, null);
}
}
But my webapi gets locked that way.
Best regards,
Rémy
|
|
|
|
|
|
Hi i am new to dot net i have a question that how does an aspx page executes without an error even after removing page load method.
Thanks in advance.
|
|
|
|
|
Because of the framework - your page inherits from the common page that has a default Load event handler...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
|
Am working in 3 tier architecture in asp.net.i wanted to learn mvc and which version i will start first (mvc 1,2,3,etc).which is the best way to study mvc in asp.net.
|
|
|
|
|
Video tutorials are the best.
If you can spend few dollars then go with Pluralsight. The best way of learning, as per my experience
http://www.pluralsight.com/training/Courses#aspdotnet
There ASP.Net MVC official site is also very good. Step by step Walk through step.
http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started
Search in Code project articles. There are plenty of articles. Follow these tutorials and try to build an application from the ground, is the best way to learn.
I am currently working with MVC 4. I recommend you to start with MVC 5 which is almost an year old.
Good luck.
|
|
|
|
|
Thank u Mr Swinkaran
|
|
|
|
|
|
Hi folks, can someone please help, I have been going round in circles with this and I’m new to ASP & C#.
Could someone please create a basic example of how to display a web user controls i.e. dropdown lists on one page and the results displaced on a second page within a Gridview.
I have store proc for the GridView, big thanks as I am losing the plot here!!!
USE [TyreSannerSQL]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[SearchResults] @Width int, @Profile int, @Diamete int, @Speed nvarchar, @CustPostcode nvarchar (50)
As
Begin
SELECT Suppliers.SupplierID, Suppliers.SupplierName, Product.Width, Product.Profile, Product.Diamete, Product.Speed, Product.Brand, Product.TyreModel, Product.TyreType,
Product.RollingResistance, Product.WetGrip, Product.NoiseEmission, Product.ProductUnitSalePrice
FROM Product INNER JOIN
Suppliers ON Product.SupplierFK = Suppliers.SupplierID
WHERE Width = @Width
and Product.Profile = @Profile
and Product.Diamete = @Diamete
and (Product.Speed = @Speed
or COALESCE(@Speed,'') = '')
and Suppliers.SupplierDistrict = LEFT(@CustPostcode,2)
ORDER BY Product.ProductUnitSalePrice ASC
End
|
|
|
|
|
When the dropdown changes you can use Response.Redirect("") to go to the page with the grid and pass the parameters through the query string.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am working on a MVC Json web service and in the web service I am making a call to Active directory. What I need to do is determine, in my code, all possible common, non-exception, types of login return values possible when an AD user attempts to login. Also, where can I find a list of all common login errors (i.e. User Not Found, etc.) and how to access the login error type in my json web service.
modified 15-Sep-14 22:25pm.
|
|
|
|
|
hello, i have ASP.net source code but i cant run it with (IIS)8, it says i don't have full permission in web.config file...And I did a lot of possible thins to fix it right but it couldnt...i would appreciate any help
|
|
|
|
|
You really need to post the exact error message.
It's usually from not setting the file permissions on the disk drive for IIS_ANONYMOUS and the app_pool identity.
You really need to search for setting permissions, the AppPool\YouNameHere is the name of the application pool, in which you go tot he IIS Manager and look up the name, or it's the name of the website you made.
[EDIT]
If your web server is a member of a domain, you should unlink it before using the code below, then relink it when done.
icacls.exe test.txt /grant "IIS AppPool\DefaultAppPool":(OI)(CI)M
cmd /c icacls test.txt /grant "IIS AppPool\DefaultAppPool:(OI)(CI)M"
You should Google the above and read up on it before applying the command, so you get the exact result you want. or else you'll have to go back and delete a bad idea to keep your site secure. Just search icals.exe
You also have to setup permissions for IIS_Anonymous for read only. I searched for a link for that
https://adminspeak.wordpress.com/tag/iis-7-5-best-practices/[^]
|
|
|
|
|
|
Hi,
I have freelance job which is about an online food order. Someone who wants to order food have to be registired. I want to add registered users to the role "member". I can handle the registiration process but I cannot add to the role member.
How can I achieve this?
I've searched but couldn't find it.
|
|
|
|
|
|
Thanks for your reply actually I tried a similar method this:
Roles.AddUsersToRoles
However that gave en exception. Until you've posted me, I did not realize your suggest.
Thanks for your help.
|
|
|
|
|
Hi,
First up, I have spent the past 2 days Googling this one. I have found many, many "solutions" but I can't get any of them to work. Part of the problem is that the solutions say to use this code or that, but don't say WHERE to put it!
So, here is the situation.
I have a page, using a Master page. I have a TreeView on the left and an Update Panel on the right. When the user selects a node in the TreeView, I add a user control to the Update Panel. (The control depends upon the type of the node - internal to my App.)
This works.
BUT, I have the need to enter a date in a User Control. I tried to use the standard Calendar control, but for some reason it's SelectedDate property isn't being updated. I then tried the JQuery-UI DatePicker tied to a text box, but it never pops up.
I know it has something to do with the AJAX reload of the Panel happening after the control is registered, but...
Anyway, if anyone can explain how to do it (not just what code to use, but WHERE to place it ) I'd be eternally grateful!
Here is what I have (I have a Calendar control in there too. Getting either to work would make me VERY happy!):
Site.Master:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Shedulinator.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<! While developing! >
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<! End dev bit>
<title>Interactive Intelligence Education Department Schedulinator</title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
<script src="Scripts/jquery-2.1.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.11.1.js" type="text/javascript"></script>
</asp:ContentPlaceHolder>
<script type="text/javascript">
$(document).ready(function () {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
$('.SiteDatePicker').datepicker({ dateFormat: 'dd-mm-yy' });
}
});
</script> </head>
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div class="page">
<div class="header">
<div class="title">
<h1>
Page Title
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
User Control:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CourseEditor.ascx.cs"
Inherits="Shedulinator.TheSettings.CourseEditor" %>
<% if (false)
{ %>
<link rel="Stylesheet" type="text/css" href="../Styles/Site.css" />
<% } %> <script type="text/javascript">
$(function () {
$('#<%=TextBoxGoLive.ClientID %>').datepicker();
});
</script>
<asp:Panel ID="Panel1" runat="server" CssClass="SettingsFormPanel">
<asp:Table ID="Table1" runat="server">
<asp:TableRow runat="server">
<asp:TableCell runat="server" RowSpan="6">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/106660-3d-glossy-orange-orb-icon-transport-travel-compass2.png"
CssClass="SettingsIcon" />
</asp:TableCell>
<asp:TableCell runat="server">
<asp:Label ID="CourseRegion" runat="server" Text="Course Title:"></asp:Label></asp:TableCell>
<asp:TableCell runat="server">
<asp:TextBox ID="TextBoxCourseTitle" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Label ID="LabelDuration" runat="server" Text="Duration"></asp:Label></asp:TableCell>
<asp:TableCell runat="server">
<asp:TextBox ID="TextBoxDuration" runat="server"></asp:TextBox>
</asp:TableCell></asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Label ID="LabelDayLength" runat="server" Text="Day Length"></asp:Label></asp:TableCell><asp:TableCell
runat="server">
<asp:TextBox ID="TextBoxDayLength" runat="server"></asp:TextBox>
</asp:TableCell></asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Label ID="LabelIsVirtual" runat="server" Text="Web Based"></asp:Label></asp:TableCell><asp:TableCell
runat="server">
<asp:CheckBox ID="CheckBoxIsVirtual" runat="server" /></asp:TableCell></asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Label ID="LabelGoLive" runat="server" Text="Go Live"></asp:Label></asp:TableCell><asp:TableCell
runat="server">
<asp:TextBox ID="TextBoxGoLive" runat="server" CssClass="SiteDatePicker"></asp:TextBox>
</asp:TableCell></asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:Label ID="LabelRetiredFrom" runat="server" Text="Retired From"></asp:Label></asp:TableCell><asp:TableCell
runat="server">
<asp:Calendar ID="CalendarRetired" runat="server" BackColor="White"></asp:Calendar>
</asp:TableCell></asp:TableRow>
</asp:Table>
<asp:Button ID="ButtonCancel" runat="server" CssClass="SettingsButton" Text="Cancel"
OnClick="ButtonCancel_Click" />
<asp:Button ID="ButtonOK" runat="server" CssClass="SettingsButton" Text="OK" OnClick="ButtonOK_Click" />
</asp:Panel>
Code behind for User Control:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Shedulinator.TheSettings
{
public partial class CourseEditor : SettingsForm
{
public event EventHandler Submit;
public event EventHandler CancelClick;
protected void Page_Load(object sender, EventArgs e)
{
reload();
}
protected void reload()
{
int CourseID = 0;
if (ItemID != null)
{
CourseID = Int16.Parse(ItemID);
}
if (CourseID > 0)
{
Course c;
using (SchedulerDatabaseDataContext dc = new SchedulerDatabaseDataContext())
{
c = dc.Courses.Where(Course => Course.CourseID == CourseID).Single();
}
TextBoxCourseTitle.Text = c.CourseTitle;
TextBoxDayLength.Text = c.DayLength.ToString();
TextBoxDuration.Text = c.Duration.ToString();
CheckBoxIsVirtual.Checked = (c.IsVirtual == 'Y');
if (c.Retired == null)
{
CalendarRetired.VisibleDate = DateTime.Today;
CalendarRetired.SelectedDates.Clear();
}
else
{
CalendarRetired.VisibleDate = (DateTime)c.Retired;
CalendarRetired.SelectedDate = (DateTime)c.Retired;
}
}
else
{
TextBoxCourseTitle.Text = "";
TextBoxDayLength.Text = "8";
TextBoxDuration.Text = "5";
CheckBoxIsVirtual.Checked = false;
CalendarRetired.VisibleDate = DateTime.Today;
CalendarRetired.SelectedDates.Clear();
}
}
protected void ButtonCancel_Click(object sender, EventArgs e)
{
reload();
if (CancelClick != null)
{
CancelClick(this, new EventArgs());
}
}
protected void ButtonOK_Click(object sender, EventArgs e)
{
using (SchedulerDatabaseDataContext dc = new SchedulerDatabaseDataContext())
{
int CourseID = 0;
if (ItemID != null)
{
CourseID = Int16.Parse(ItemID);
}
Course c;
if (CourseID == -1)
{
c = new Course();
dc.Connection.Open();
Course C = dc.Courses.OrderByDescending(Course => Course.CourseID).FirstOrDefault();
c.CourseID = (null == C ? 0 : C.CourseID) + 1;
}
else
{
c = dc.Courses.Where(Course => Course.CourseID == CourseID).Single();
}
c.CourseTitle = TextBoxCourseTitle.Text;
c.Duration = int.Parse(TextBoxDuration.Text);
c.DayLength = int.Parse(TextBoxDayLength.Text);
c.IsVirtual = (CheckBoxIsVirtual.Checked ? 'Y' : 'N');
if (CalendarRetired.SelectedDates.Count>0)
{
c.Retired = CalendarRetired.SelectedDate;
}
if (CourseID == -1)
{
dc.Courses.InsertOnSubmit(c);
}
dc.SubmitChanges();
}
if (Submit != null)
{
Submit(this, new EventArgs());
}
}
}
}
Paul
|
|
|
|
|
Let's fix one thing at a time, so I'll tackle the datepicker
I didn't see an update panel, so if there is none, the try will catch the error and contrinue to load the script.
Make sure you place the code below in the web form's, content place holder and not the master page like in your example.
I personally don't like the jquery.ui everthing, and prefer to just load the core, and the datepicker.
I switched the way you discover the textbox to bind to from css to the actual id of the textbox, using a wildcard to filter anything the is prefixed in front of the actual ID name of the textbox, will is standard behavior for using an update panel, in which $CT100_ is prefixed.
WebForm.aspx
<asp:Content ID="HeadContent" ContentPlaceHolderID="HeadContent" runat="Server">
<script src="Scripts/jquery.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-core.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-datepicker.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
initializeBinding();
try {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}
catch (e) {
}
});
function EndRequestHandler(sender, args) {
initializeBinding();
}
function initializeBinding() {
$('[id*="TextBoxGoLive"]').datepicker({
autoSize: true
});
}
</script>
</asp:Content>
[EDIT]
Test the code on your dev machine, using internet explorer 9+, and press F12 in IE, and clickon the bug for Debug. IE will throw an error like the webdev highlighting the error in yellow and red, showing where the script failed and why.
Then fix the error and run it again.
[EDIT 2]
Fix the path of the scripts, by deleting them, and using the project explorer to drag the jquery file into the editor, in which the correct path will be generated for that page.
|
|
|
|
|