 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
I have a register form to make. But client side validation not working properly. Can anyone help me out.
Thanks in Advance.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="Register" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script language="javascript" type="text/javascript">
function Validate() {
var summary = "";
summary += isValidName();
summary += isValidEmail();
summary += isValidMobile();
if (summary != "") {
return false;
}
else {
return true;
}
}
function isValidName() {
var Name = document.getElementById("TxtName");
if (Name.value == "") {
alert('Please provide a valid Name');
Name.focus;
return false
}
else {
return "";
}
}
function isValidEmail() {
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;
}
}
function isValidMobile() {
var Mobile = document.getElementById("TxtMoible");
if (Mobile.value == "") {
alert('Please provide a valid Mobile');
Mobile.focus;
return false
}
else {
return "";
}
}
</script>
</head>
<body>
<%--<form name="myForm" action="demo_form.asp" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">--%>
<form id="form1" runat="server">
<div>
<table style="width:100%;">
<tr>
<td>
Name
</td>
<td>
<input id="TxtName" type="text" /></td>
<td>
</td>
</tr>
<tr>
<td>
Email ID</td>
<td>
<input id="TxtEmail" type="text" /></td>
<td>
</td>
</tr>
<tr>
<td>
Confirm Email ID</td>
<td>
<input id="TxtConfirmEmail" type="text" /></td>
<td>
</td>
</tr>
<tr>
<td>
Password</td>
<td>
<input id="TxtPass" type="text" /></td>
<td>
</td>
</tr>
<tr>
<td>
Confirm Password</td>
<td>
<input id="TxtConfirmPass" type="text" /></td>
<td>
</td>
</tr>
<tr>
<td>
Mobile No.</td>
<td>
<input id="TxtMobile" type="text" /></td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="BtnSubmit" runat="server" onClientClick="return Validate();"
onClick="Button1_Click" Text="Register Now" />
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</form>
</body>
</html>
|
|
|
|
 |
In case all values are valid you get 'undefined' in summary, and that because your isValidEmail method has not defined return value in case of valid input!!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
 |
I am developing an ASP.net application wherein I am trying to connect to Oracle database using sqldatasource. While defining new connection, when i click on test connection button on the dialog box, I am getting error:
Error 12541 - TNS: no listener.
My oracle listener is up. Kindly help me in getting rid of this error.
|
|
|
|
 |
Are you connecting to a remote Oracle server, or is the Oracle server running on your desktop computer?
If your connecting to a remote Oracle Server, there is a long process you have to go through to setup the listener.
I think there are 2 programs you have to load to complete the listener for asp.net. I haven't done it in couple of years, but it required some research and implementation.
http://docs.oracle.com/cd/E51173_01/win.122/e17733/IntroInstallation.htm#ASPNT116[^]
|
|
|
|
 |
Thanks for the info friend.
I have already installed ODAC and as per your guidance also followed the instructions given on the page provided by you. But unfortunately it didn't work.
|
|
|
|
 |
Your gonna have to check if the listener is even running, check the port on the firewall, and so forth in order to get it working.
But you never said if the Oracle database software is running remote or local, 2 different sets of items to check.
It's really no different than configuring MySQL or SQL Server. You may want to start searching post on the oracle website to get some ideas of what to do.
https://community.oracle.com/thread/371929?tstart=0[^]
|
|
|
|
 |
Hi There,
Can anyone help, I am having trouble posting a form to a Table in my database. I am getting a ERROR "Procedure or function SPInsertIndividual has too many arguments specified.", Can anyone help it would be very much appreciated.
My SP Code is:
CREATE PROCEDURE [dbo].[SPInsertIndividual]
(
@IndividualID int OUTPUT,
@TypeName nvarchar(200),
@RankName nvarchar(200),
@TitleName nvarchar(200),
@FamilyName nvarchar(200),
@FirstName nvarchar(200),
@MiddleName1 nvarchar(200),
@MiddleName2 nvarchar(200),
@MiddleName3 nvarchar(200),
@Gender nvarchar(20),
@DOB nvarchar(200),
@CountryName nvarchar(200),
@StateName nvarchar(200),
@CityName nvarchar(200),
@Verification nvarchar(200),
@DateCreated DateTime
)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO dbo.tblIndividual(TypeName, RankName, TitleName, FamilyName, FirstName, MiddleName1, MiddleName2, MiddleName3, Gender, DOB, CountryName, StateName, CityName, Verification, DateCreated, IndividualID)
VALUES(@TypeName, @RankName, @TitleName, @FamilyName, @FirstName, @MiddleName1, @MiddleName2, @MiddleName3, @Gender, @DOB, @CountryName, @StateName, @CityName, @Verification, @DateCreated, @IndividualID)
END
Aspx.cs Code is
protected void btnSubmit_Click(object sender, EventArgs e)
{
String strConnString = ConfigurationManager.ConnectionStrings["AspGenealogy"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SPInsertIndividual";
var id = new SqlParameter("IndividualID", System.Data.SqlDbType.Int);
id.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add(id);
cmd.Parameters.Add("@IndividualID", SqlDbType.Int);
cmd.Parameters.Add("@TypeName", SqlDbType.VarChar).Value = ddlType.SelectedItem.Text.Trim();
cmd.Parameters.Add("@RankName", SqlDbType.VarChar).Value = ddlRank.SelectedItem.Text.Trim();
cmd.Parameters.Add("@TitleName", SqlDbType.VarChar).Value = ddlTitle.SelectedItem.Text.Trim();
cmd.Parameters.Add("@FamilyName", SqlDbType.VarChar).Value = txtFamilyName.Text.Trim();
cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = txtFirstName.Text.Trim();
cmd.Parameters.Add("@MiddleName1", SqlDbType.VarChar).Value = txtMiddleName1.Text.Trim();
cmd.Parameters.Add("@MiddleName2", SqlDbType.VarChar).Value = txtMiddleName2.Text.Trim();
cmd.Parameters.Add("@MiddleName3", SqlDbType.VarChar).Value = txtMiddleName3.Text.Trim();
cmd.Parameters.Add("@Gender", SqlDbType.VarChar).Value = ddlGender.SelectedItem.Text.Trim();
cmd.Parameters.Add("@DOB", SqlDbType.VarChar).Value = txtDOB.Text.Trim();
cmd.Parameters.Add("@CountryName", SqlDbType.VarChar).Value = ddlCountry.SelectedItem.Text.Trim();
cmd.Parameters.Add("@StateName", SqlDbType.VarChar).Value = ddlState.SelectedItem.Text.Trim();
cmd.Parameters.Add("@CityName", SqlDbType.VarChar).Value = ddlCity.SelectedItem.Text.Trim();
cmd.Parameters.Add("@Verification", SqlDbType.VarChar).Value = txtVerification.Text.Trim();
cmd.Parameters.Add("@DateCreated", SqlDbType.DateTime).Value = DateTime.Now;
cmd.Connection = con;
try
{
con.Open();
cmd.ExecuteNonQuery();
Response.Redirect("Details.aspx");
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
My .aspx code is:
<body>
<form id="form1" runat="server">
<div style="font-family:Gabriola">
<fieldset style="width:380px">
<legend><h3>Individual Builder: Stage 1</h3></legend>
<tr>
<td>
Type:
</td>
<td>
<asp:DropDownList ID="ddlType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlType_SelectedIndexChanged" DataTextField="TypeName" DataValueField="TypeID"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
Rank:
</td>
<td>
<asp:DropDownList ID="ddlRank" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlRank_SelectedIndexChanged" DataTextField="RankName" DataValueField="RankID"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
Title:
</td>
<td>
<asp:DropDownList ID="ddlTitle" AutoPostBack="true" runat="server" DataTextField="TitleName" DataValueField="TitleID"></asp:DropDownList>
</td>
</tr>
______________________________________________________________________________________________________________________________________________
<tr>
<td>
Family Name:
</td>
<td>
<asp:TextBox ID="txtFamilyName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
First Name:
</td>
<td>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Middle Name:
</td>
<td>
<asp:TextBox ID="txtMiddleName1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Middle Name:
</td>
<td>
<asp:TextBox ID="txtMiddleName2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Middle Name:
</td>
<td>
<asp:TextBox ID="txtMiddleName3" runat="server"></asp:TextBox>
</td>
</tr>
______________________________________________________________________________________________________________________________________________
<tr>
<td>
Gender:
</td>
<td>
<asp:DropDownList ID="ddlGender" runat="server">
<asp:ListItem Value="0">Male</asp:ListItem>
<asp:ListItem Value="1">Female</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Date of Birth:
</td>
<td>
<asp:TextBox ID="txtDOB" runat="server"></asp:TextBox>
</td>
</tr>
______________________________________________________________________________________________________________________________________________
<tr>
<td>
Country of Birth:
</td>
<td>
<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" style="height: 22px" DataTextField="CountryName" DataValueField="CountryID"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
Province or State of Birth:
</td>
<td>
<asp:DropDownList ID="ddlState" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlState_SelectedIndexChanged" DataTextField="StateName" DataValueField="StateID"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
City of Birth:
</td>
<td>
<asp:DropDownList ID="ddlCity" runat="server" AutoPostBack="true" DataTextField="CityName" DataValueField="CityID"></asp:DropDownList>
</td>
</tr>
______________________________________________________________________________________________________________________________________________
<tr>
<td>
Source:
</td>
<td>
<asp:TextBox ID="txtVerification" runat="server"></asp:TextBox>
</td>
</tr>
______________________________________________________________________________________________________________________________________________
<tr>
<td>
<asp:Button ID="btnClear" runat="server" Text="Clear" />
</td>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"/>
</td>
</tr>
</fieldset>
</div>
</form>
</body>
Can anyone help me? I am sure it is something minor.
Thanks, I look forward to hearing from you.
|
|
|
|
 |
Member 9142936 wrote: var id = new SqlParameter("IndividualID", System.Data.SqlDbType.Int);
id.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add(id);
cmd.Parameters.Add("@IndividualID", SqlDbType.Int);
You've added the @IndividualID parameter twice.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
don't know if this is due to poor db design or not but I have been struggling since last night to update some records from by selecting the values of records to be updated from a dynamically populated dropdownlist from a lookup table.
Essentially, we have three tables called Courses, Instructors and CourseInstructor tables.
CourseInstructor table is a bridge table between Courses and Instructor tables.
So, when adding courses and instructors to their various tables, their foreign keys are automatically added to the bridge table.
This seems to work fine so far.
However, users are having difficulties making changes to these tables.
For instance, if a user wishes to replace one instructor with another, she has not been to do so for far. After an update, the message indicates successful update the instructor names don't change.
Any ideas what I could have done wrong with the code below?
<asp:TemplateField HeaderText="Instructor">
<EditItemTemplate>
<asp:DropDownList ID="ddlInstructors" runat="server" AppendDataBoundItems="True" DataSourceID="SubjectDataSource"
DataTextField="InstructorName" DataValueField="InstructorId">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblInstructors" runat="server" Text='<% #Bind("InstructorName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:SqlDataSource ID="sqlDataSourceloc" runat="server"
ConnectionString="<%$ ConnectionStrings:DBConn %>"
SelectCommand="SELECT locationId, Location FROM Locations order by location asc"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
UpdateCommand = "Update tblCourseInstructor Set CourseId = @CourseId where (CourseId =@CourseId) Update tblCourseInstructor set InstructorId=@InstructorId where (instructorId=@instructorId and courseId = @courseId)"
SelectCommand="select l.locationid,c.CourseId, i.instructorId,CourseName, i.instructorname, dbo.fnFormatDate(t.trainingDates, 'MON/DD/YYYY') trainingDates, t.trainingTime,CourseDescription from Courses c, tblLocations l, TrainingDates t, Instructors i, CourseInstructor ci where l.locationid = c.locationid and c.dateId = t.dateId and i.instructorid = ci.instructorId and c.courseid=ci.courseid and YEAR(t.trainingDates) = YEAR(getDate())"
FilterExpression="LocationId = '{0}'" >
<FilterParameters>
<asp:ControlParameter ControlID="ddlLocation" Name="LocationId" PropertyName="SelectedValue" Type="Int32" />
</FilterParameters>
<UpdateParameters>
<asp:Parameter Name="CourseId" Type="Int32" />
<asp:Parameter Name="instructorId" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SubjectDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DBConn %>"
SelectCommand="SELECT instructorId, InstructorName FROM dbo.Instructors order by InstructorName">
</asp:SqlDataSource>
Then I tried updating it from codebehind with code below
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim ddAssigned As DropDownList = DirectCast(GridView1.Rows(e.RowIndex).FindControl("ddlInstructors"), DropDownList)
e.NewValues("instructorId") = ddAssigned.SelectedValue
SubjectDataSource.DataBind()
End Sub
but got the following error:
'SqlDataSource1' unless UpdateCommand is specified.
Any ideas how do I fixt this one?
|
|
|
|
 |
I'm taking a big guess here on this, but I think this is your problem.
I wanna say that it's a bad design, but I haven't seen the design, but the CourseID should say the same if your just updating the teacher
UpdateCommand = _
"Update tblCourseInstructor Set CourseId = @CourseId where (CourseId =@CourseId) " & _
"Update tblCourseInstructor set InstructorId=@InstructorId where (instructorId=@instructorId and courseId = @courseId)"
<pre>
UpdateCommand = _
"Update tblCourseInstructor set InstructorId=@InstructorId where courseId = @courseId)"
</pre>
|
|
|
|
 |
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 4 days ago.
|
|
|
|
 |
Message Automatically Removed
|
|
|
|
 |
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.
|
|
|
|
|
 |
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.
|
|
|
|
 |
Hello
I am getting the following error message:
Server Error in '/' Application.
The resource cannot be found.
Requested URL: /Account/success.aspx
This is a Web form which inserts field data into a MS Access database and redirects the user to a 'You have successfully registered page'.
Everything was working fine locally until I decided to personalise it to show 'JohnSmith, you have successfully registered'.
I did that by adding the following to my register.aspx.vb file:
Response.Redirect("success.aspx?Data=" & Server.UrlEncode(username.Text))
and this to my success.aspx.vb file:
'Partial Class success
'Inherits System.Web.UI.Page
'End Class
Public Class success
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
What could be the problem here, please?
Thanks!
|
|
|
|
 |
Member 8761667 wrote: What could be the problem here, please? Well, the error is pretty clear. The page /Account/success.aspx does not exist.
When you do Response.Redirect you likely will want to go to the root of the app and make your path from there so that if you deploy under a different structure, the code will still work. All you likely need to do is add ~ to your Response.Redirect.
Response.Redirect("~/success.aspx?Data=" & Server.UrlEncode(username.Text))
~/ will move to the root of the site.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
That's great 8761667
Thank you.
The error has gone but for some reason the 'You have successfully registered' is still not personalised.
The script that I added I basically got from a Microsoft tutorial.
|
|
|
|
 |
You're passing the username through the querystring but then never using it, at least not in the data you showed.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
How would I do that, Ryan? This is my first venture into asp.net.
|
|
|
|
 |
I suggest getting a book or going through online tutorials.
A simple method is to add a label and then in Page_Load take the value from Request.QueryString and put it into the label. But this is such basic stuff that I think you'll learn a lot more if you go through tutorials.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
Yes, OK, I will do.
Thanks
|
|
|
|
 |
A word of warning: Don't do what Ryan said. (Or at least, not exactly what he said!)
When you take a value from the request and want to re-display it, you need to make sure it's properly encoded. In this case, since you're display it as text within the HTML of the page, you need to use the HttpUtility.HtmlEncode method[^] to encode the string before showing it in a label.
The reason you need to encode it before displaying it is to prevent a cross-site scripting (XSS)[^] attack. Since the query-string could be modified by the user, they could pass in any HTML or javascript. If your code blindly copies that to the response, they can execute that script within your page. Since it's just a link, they could send that out to anyone they think might use your site, and anyone who clicked on the link would suddenly find that their authentication cookies have been stolen, or that your site has installed malware on their device.
You should never trust any input that comes from the user, whether it's in the query-string, part of a POST request, or even the HTTP headers. Always assume that all users are trying to hack into your site, and use the appropriate defences.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hello Richard
Thanks for your post.
So in addition to this if I can get it to work:
Public Class success
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request("Name") IsNot Nothing Then
Name.Text = String.Format("{0}, ", Request("Name"))
End If
End Sub
End Class
I would also need the basis of something like this (which looks complicated!):
Imports System
Imports System.Web
Imports System.IO
Class MyNewClass
Public Shared Sub Main()
Dim myString As String
Console.WriteLine("Enter a string having '&' or '""' in it: ")
myString = Console.ReadLine()
Dim myEncodedString As String
' Encode the string.
myEncodedString = HttpUtility.HtmlEncode(myString)
Console.WriteLine("HTML Encoded string is " + myEncodedString)
Dim myWriter As New StringWriter()
' Decode the encoded string.
HttpUtility.HtmlDecode(myEncodedString, myWriter)
Console.Write("Decoded string of the above encoded string is " + myWriter.ToString())
End Sub 'Main
End Class 'MyNewClass
As an aside, my 'you have successfully registered' page tells me after I complete the form myself:
'System.Web.UI.WebControls.TextBox, You have successfully registered'.
I can see 'System.Web.UI.WebControls.TextBox' if I hover my mouse over the word 'username' in my Register.aspx.vb file, but I don't know what the source of the error is.
Thanks again, Richard.
|
|
|
|
 |
You don't really need the console application, unless you want to play with the methods. All you really need is:
Public Class success
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim theName As String = Request.QueryString("Name")
If Not String.IsNullOrEmpty(theName) Then
Name.Text = HttpUtility.HtmlEncode(theName)
End If
End Sub
End Class
As for the page displaying your name as System.Web.UI.WebControls.TextBox , it sounds like you're doing something like:
Response.Redirect(String.Format("success.aspx?name={0}", UserNameTextBox))
You need to pass the value of the TextBox , which is in the .Text property. You should also make sure that you properly encode the value - this time, for a URL:
Dim theName As String = UserNameTextBox.Text
Dim encodedName = HttpUtility.UrlEncode(theName)
Response.Redirect(String.Format("success.aspx?name={0}", encodedName))
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Thanks for that, Richard.
This finally worked:
register.aspx.vb
Dim target = String.Format("~/Success.aspx?Name={0}", username.Text)
' Perform your Redirect '
Response.Redirect(target, True)
success.aspx.vb
Public Class success
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request("Name") IsNot Nothing Then
' It exists, so set your label (and a trailing comma) to display your name '
Name.Text = String.Format("{0}, ", Request("Name"))
End If
End Sub
End Class
Thanks for your help and for giving me an idea of what to look for.
|
|
|
|
 |
That looks very much like the original code you posted. You're missing all of the required encoding.
For example, try entering a username of <script>alert("Test")</script> - you'll either get a message box pop up when the success page loads, or your browser will prevent access to the page with a warning about cross-site scripting.
You need to encode the value according to the context:
register.aspx.vb:
Dim name As String = HttpUtility.UrlEncode(username.Text)
Dim target As String = String.Format("~/Success.aspx?Name={0}", name)
Response.Redirect(target, True)
success.aspx.vb:
Public Class success
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim theName As String = Request.QueryString("Name")
If Not String.IsNullOrEmpty(theName) Then
Dim encodedName As String = HttpUtility.HtmlEncode(theName)
Name.Text = String.Format("{0}, ", encodedName)
End If
End Sub
End Class
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hello Richard
Thanks for that.
I actually have in aspx.vb:
Dim target = String.Format("~/Success.aspx?Name={0}", username.Text)
' Perform your Redirect '
Response.Redirect(target, True)
and in success.aspx.vb:
Public Class success
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request("Name") IsNot Nothing Then
' It exists, so set your label (and a trailing comma) to display your name '
Name.Text = String.Format("{0}, ", Request("Name"))
End If
End Sub
End Class
That seems to work, but I don't have HttpUtility.UrlEncode or HttpUtility.HtmlEncode.
Thanks again for your time.
|
|
|
|
 |
Richard Deeming wrote: it is to prevent a cross-site scripting (XSS)[^] attack. Yes, I intentionally left that out as to not overwhelm, but valid point.
Note, most browsers do a good job preventing that anyway.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
I have an unordered list of Html.ActionLinks that work just fine except now we want the Admin link to become a hover dropdown with the actual Html.ActionLinks to be contained in the sub-menu items. What I have done is wrap<div> around the main Admin menu item on the Main menu bar and child <div> below. First below is the code I am using to do this:
VIEW
<ul>
<li>@Html.ActionLink("Home", "Index", "Home")|</li>
<li>@Html.ActionLink("My Account", "", "")|</li>
<li>@Html.ActionLink("Admin", "Index", "Admin")|</li>
</ul>
<div align="center">
<div class="content_head">
Admin Main Menu
</div>
<div class="content_body">
@Html.ActionLink("Admin Page", "Index", "Admin")
</div>
<div class="content_body">
@Html.ActionLink("Admin Info", "Index", "Admin")
</div>
</div>
<ul>
<li>@Html.ActionLink("Log Out", "LogOffAbacus", "Home")</li>
</ul>
}
SITE.css
.content_head {
width: 150px;
height: 30px;
background-color: #CCCCCC;
cursor: pointer;
}
.content_body {
display: none;
width: 150px;
height: 50px;
background-color: #9999FF;
}
SITE.js
$(".content_head").hover(function () {
$(".content_body").hide(100);
$(this).next(".content_body").slideToggle("slow");
})n;
Now, this does not work because of jQuery error "Microsoft JScript runtime error: Object expected" and I am unsure why. Now the big question, this method looks likes a bad way of doing this. Is there a better way to do this?
.
|
|
|
|
 |
guys;
I gave a problem with __VIEWSTATE hidden input it lays on the page like a huge spider web. I want to reduce its size efficiently without adding enableViewState="false" to every control.
is it possible to do so?
Help people,so poeple can help you.
|
|
|
|
|
 |
|