|
You could use a regex or the DOM model to find the specific tags you are interested in.
|
|
|
|
|
|
Back for more help, sorry.
After all that struggle to get my project working in php, they came back on Wednesday last week that they could not use current project written in php because the wordpress theme that the php would be integrated with is not set up correctly to allow us the ability to upload the file as a template and we could gain access to MySQL database.
So, I had to start all over building the app in asp.net.
I have been working on this since Wednesday last week.
For the most part, I think I got most it working. I was able to rewrite the dynamic row addition.
I am currently trying to use JSON object with an ajax call to submit the records into the database.
The issue right now, however, is that I get, my custom error message which says, "Error while inserting data".
Sorry for the long code. I am posting them because I am not sure what is causing the error, whether it is coming from my HTML markup or codefile.
Any ideas, as always, is greatly appreciated.
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(document).on("click", "#btnAdd", function () {
var rowCount = $('.data-contact-person').length + 1;
var contactdiv = '<tr class="data-contact-person">' +
'<td><input type="text" style="width:200px;" name="sourcename' + rowCount + '" class="form-control sourcename01" /></td>' +
'<td><input type="text" style="width:200px;" name="sourceaddress' + rowCount + '" class="form-control sourceaddress01" /></td>' +
'<td><input type="text" style="width:200px;" name="sourceincome' + rowCount + '" class="form-control sourceincome01" /></td>' +
'<td style="width:200px;"><button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>' +
'<button type="button" id="btnDelete1" class="deleteContact btn btn btn-danger btn-xs">Remove</button></td>' +
'</tr>';
$('#maintable').append(contactdiv);
});
$(document).on("click", "#btnAdd2", function () {
var rowCount = $('.data-contact-person2').length + 1;
var contactdiv = '<tr class="data-contact-person2">' +
'<td><input type="text" style="width:200px;" name="spousename' + rowCount + '" class="form-control spousename01" /></td>' +
'<td><input type="text" style="width:200px;" name="spouseaddress' + rowCount + '" class="form-control spouseaddress01" /></td>' +
'<td><input type="text" style="width:200px;" name="spouseincome' + rowCount + '" class="form-control spouseincome01" /></td>' +
'<td><button type="button" id="btnAdd2" class="btn btn-xs btn-primary classAdd">Add More</button>' +
'<button type="button" id="btnDelete2" class="deleteContact btn btn btn-danger btn-xs">Add More</button></td>' +
'</tr>';
$('#maintable2').append(contactdiv);
});
$(document).on("click", ".deleteContact", function () {
$(this).closest("tr").remove();
});
function getAllEmpData() {
var data = [];
$('tr.data-contact-person').each(function () {
var sname = $(this).find('.sourcename01').val();
var saddress = $(this).find('.sourceaddress01').val();
var sincome = $(this).find('.sourceincome01').val();
var spname = $(this).find('.spousename01').val();
var spaddress = $(this).find('.spouseaddress01').val();
var spincome = $(this).find('.spouseincome01').val();
var alldata = {
'mySource': sname,
'mySAddress': saddress,
'mySIncome': sincome,
'mySpouse': spname,
'mySPAddress': spaddress,
'mySPIncome': spincome
}
data.push(alldata);
});
console.log(data);
return data;
}
$("#btnSubmit").click(function () {
var data = JSON.stringify(getAllEmpData());
$.ajax({
url: 'disclosures.aspx/SaveData',
type: 'POST',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({ 'empdata': data }),
success: function () {
alert("Data Added Successfully");
},
error: function () {
alert("Error while inserting data");
}
});
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h2>Forms</h2>
<table class="table" id="maintable">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Income</th>
</tr>
</thead>
<tbody>
<tr class="data-contact-person">
<td>
<input type="text" style="width:200px;" name="sourcename" class="form-control sourcename01" /></td>
<td>
<input type="text" style="width:200px;" name="sourceaddress" class="form-control sourceaddress01" /></td>
<td>
<input type="text" style="width:200px;" name="sourceincome" class="form-control sourceincome01" /></td>
<td style="width:200px;">
<button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>
</td>
</tr>
</tbody>
</table>
<table class="table" id="maintable2">
<thead>
<tr>
<th>Source </th>
<th>Address </th>
<th>Income</th>
</tr>
</thead>
<tbody>
<tr class="data-contact-person2">
<td>
<input type="text" style="width:200px;" name="spousename" class="form-control spousename01" /></td>
<td>
<input type="text" style="width:200px;" name="spouseaddress" class="form-control spouseaddress01" /></td>
<td>
<input type="text" style="width:200px;" name="spouseincome" class="form-control spouseincome01" /></td>
<td style="width:200px;">
<button type="button" id="btnAdd2" class="btn btn-xs btn-primary classAdd2">Add More</button>
</td>
</tr>
</tbody>
</table>
<button type="button" id="btnSubmit" class="btn btn-primary btn-md pull-right btn-sm">Submit</button>
</div>
</form>
</body>
</html>
'//CodeFile
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Linq
Imports System.Web
Imports System.Web.Services
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Newtonsoft.Json
Partial Public Class disclosures
Inherits System.Web.UI.Page
Public Shared Constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Protected Sub Page_Load(sender As Object, e As EventArgs)
End Sub
<WebMethod()> _
Public Shared Function SaveData(empdata As String) As String
Dim serializedData = JsonConvert.DeserializeObject(Of List(Of Employee))(empdata)
Using con = New SqlConnection(Constr)
If con.State = ConnectionState.Closed Then
con.Open()
End If
For Each data As Employee In serializedData
Using cmd = New SqlCommand("INSERT INTO SourceDetails(sourcename, sourceaddress, sourceincome, createDate) VALUES(@sname, @saddress,@sincome,@CreatedDate)")
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@sname", data.mySpouse)
cmd.Parameters.AddWithValue("@saddress", data.mySAddress)
cmd.Parameters.AddWithValue("@sincome", data.mySIncome)
cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now)
cmd.Connection = con
cmd.ExecuteNonQuery()
End Using
Next
con.Close()
End Using
Return Nothing
End Function
End Class
Public Class Employee
Public Property mySpouse() As String
Get
Return m_mySpouse
End Get
Set(value As String)
m_mySpouse = value
End Set
End Property
Private m_mySpouse As String
Public Property mySAddress() As String
Get
Return m_mySAddress
End Get
Set(value As String)
m_mySAddress = value
End Set
End Property
Private m_mySAddress As String
Public Property mySIncome() As String
Get
Return m_mySIncome
End Get
Set(value As String)
m_mySIncome = value
End Set
End Property
Private m_mySIncome As String
Public Property CreatedDate() As DateTime
Get
Return m_CreatedDate
End Get
Set(value As DateTime)
m_CreatedDate = Value
End Set
End Property
Private m_CreatedDate As DateTime
End Class
modified 6-Mar-17 9:35am.
|
|
|
|
|
You fail to check the return value from your call to cmd.ExecuteNonQuery() , so you have no way of knowing whether that succeeded or not. In your ajax calls, where do the success or failure statuses come from, and what other status information is available?
|
|
|
|
|
Hi Richard,
Many thanks for attempting to help.
My experience with ajax call and JSON object WebMethods() tells me that you can't get to codebehind unless you get beyond the alert() message.
I could be wrong so far but to answer your question, I think that using
console.log(data); tells me what values are being passed to getAllEmpData and then to #btnsubmit control.
For instance, when I tried to use firebug to inspect the code, I got the following:
SCRIPT16389: Unspecified error.
[object Object],[object Object]
[{},{"mySource":"Martin Short","mySAddress":"1 Hollywood Way","mySIncome":"3401221"}]
This tells me that returning
[object Object],[object Object] is a problem somewhere with function because the correct information I entered from markup is captured and displayed as JSON objects below
[object Object],[object Object] .
I just don't know what is causing it.
Hope I am making sense.
|
|
|
|
|
The trouble is that message tells you (and us) nothing useful. And I am afraid I don't know AJAX, so cannot suggest anything on that score. Obviously adding some logging information should go some way to helping you to a solution.
|
|
|
|
|
Ok,
I will keep at it.
I would have preferred to NOT go this route of using JSON and Ajax calls but I have not been able to figure out a way to continue using the code Richard D wrote for using AngularJS with the PHP bit.
Thanks for your help though.
|
|
|
|
|
I'd start by using Fiddler or the browser's dev tools to see what is being passed to and from your webmethod as that can often help tracking down issues, and if your server code is throwing an exception it often lets you see what that exception is
Using the browser's dev tools to diagnose ajax problems (and other things) | The ASP.NET Forums[^]
I'd also debug the webmethod at the project to inspect the data come into the method and to see if the deserialisation is working or if the code is throwing exceptions.
|
|
|
|
|
I am still pretty stumped by this issue.
I have moved past the initial problem.
Right now, when i run the app, it is inserting records to the database correctly.
However, this works for only one class.
When I add a second class or table, I start getting a very deceitful error message.
For instance, when I run the app with one class:
It works.
When I run the second class separately too, it works as well.
However, when I combine them which is the real intent of this project, I keep getting "parameter @name is required but not supplied"
I have tested the stored procedure that I am using in Sql Server Management Studio and it works fine.
There is one critical step that I am missing but not sure how to fix this. I wonder if it is not possible to have multiple INSERT statements using Ajax and webmethods.
Below is the code that I am currently using.
<script type="text/javascript">
$(document).ready(function () {
$(document).on("click", "#empAdd", function () {
var rowCount = $('.data-contact-person').length + 1;
var contactdiv = '<tr class="data-contact-personm">' +
'<td><input type="text" style="width:200px;" name="employeename' + rowCount + '" placeholder="Your name..." class="form-control employeename01" /></td>' +
'<td><input type="text" style="width:200px;" name="employeetitle' + rowCount + '" placeholder="Your title..." class="form-control employeetitle01" /></td>' +
'<td><input type="text" style="width:200px;" name="employeeemail' + rowCount + '" placeholder="Your email address..." class="form-control employeeemail01" /></td>' +
'<td style="width:200px;"><button type="button" id="empAdd" class="btn btn-xs btn-primary classAdd">Add More</button>' +
'<button type="button" id="empDeletem" class="deleteContact btn btn btn-danger btn-xs">Remove</button></td>' +
'</tr>';
$('#emptable').append(contactdiv);
});
$(document).ready(function () {
$(document).on("click", "#btnAdd", function () {
var rowCount = $('.data-contact-person').length + 1;
var contactdiv = '<tr class="data-contact-person">' +
'<td><input type="text" style="width:200px;" name="sourcename' + rowCount + '" placeholder="Name of income source..." class="form-control sourcename01" /></td>' +
'<td><input type="text" style="width:200px;" name="sourceaddress' + rowCount + '" placeholder="Address of income source..." class="form-control sourceaddress01" /></td>' +
'<td><input type="text" style="width:200px;" name="sourceincome' + rowCount + '" placeholder="Income..." class="form-control sourceincome01" /></td>' +
'<td style="width:200px;"><button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>' +
'<button type="button" id="btnDelete1" class="deleteContact btn btn btn-danger btn-xs">Remove</button></td>' +
'</tr>';
$('#maintable').append(contactdiv);
});
$(document).on("click", ".deleteContact", function () {
$(this).closest("tr").remove();
});
function getAllSourcepData() {
var data = [];
$('tr.data-contact-person').each(function () {
var ename = $(this).find('.employeename01').val();
var etitle = $(this).find('.employeetitle01').val();
var email = $(this).find('.employeeemail01').val();
var sname = $(this).find('.sourcename01').val();
var saddress = $(this).find('.sourceaddress01').val();
var sincome = $(this).find('.sourceincome01').val();
var alldata = {
'emplName': ename,
'emplTitle': etitle,
'empMail': email,
'mySource': sname,
'mySAddress': saddress,
'mySIncome': sincome
}
data.push(alldata);
});
console.log(data);
return data;
}
$("#btnSubmit").click(function () {
var data = JSON.stringify(getAllEmpData());
var data = JSON.stringify(getAllSourcepData());
console.log(data);
$.ajax({
url: 'disclosures.aspx/SaveData',
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({ 'empdata': data }),
success: function () {
alert("Data Added Successfully");
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
});
});
});
</script>
<style type="text/css">
.bs-example{
margin-left: 250px;
margin-top: 30px;
}
</style>
</head>
<body>
<div class="bs-example">
<form id="form1" runat="server">
<div class="container">
<table id="emptable">
<thead>
<tr>
<th>Employee Name</th>
<th>Title</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr class="data-contact-person">
<td>
<input type="text" style="width:200px;" name="employeename" class="form-control employeename01" placeholder="Your name..." /></td>
<td>
<input type="text" style="width:200px;" name="employeetitle" class="form-control employeetitle01" placeholder="Your title..." /></td>
<td>
<input type="text" style="width:200px;" name="employeeemail" class="form-control employeeemail01" placeholder="Your email address..." /></td>
<td>
</td>
</tr>
</tbody>
</table><br /><br />
<table id="maintable">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Income</th>
</tr>
</thead>
<tbody>
<tr class="data-contact-person">
<td>
<input type="text" style="width:200px;" name="sourcename" class="form-control sourcename01" placeholder="Name of income source..." /></td>
<td>
<input type="text" style="width:200px;" name="sourceaddress" class="form-control sourceaddress01" placeholder="Address of income source..." /></td>
<td>
<input type="text" style="width:200px;" name="sourceincome" class="form-control sourceincome01" placeholder="Income..." /></td>
<td style="width:200px;">
<button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>
</td>
</tr>
</tbody>
</table><br /><br />
<button type="button" id="btnSubmit" class="btn btn-primary btn-md pull-center btn-sm">Submit</button>
</div>
</form>
Below is code behind:
<WebMethod()> _
Public Shared Function SaveData(empdata As String) As String
Dim serializedData = JsonConvert.DeserializeObject(Of List(Of Employee))(empdata)
Using con = New SqlConnection(Constr)
If con.State = ConnectionState.Closed Then
con.Open()
End If
For Each data As Employee In serializedData
Using cmd = New SqlCommand("sprInsertDisclsosures")
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@ename", data.emplName)
cmd.Parameters.AddWithValue("@email", data.emplTitle)
cmd.Parameters.AddWithValue("@title", data.empMail)
cmd.Parameters.AddWithValue("@sname", data.mySource)
cmd.Parameters.AddWithValue("@saddress", data.mySAddress)
cmd.Parameters.AddWithValue("@sincome", data.mySIncome)
' cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now)
cmd.Connection = con
cmd.ExecuteNonQuery()
End Using
Next
con.Close()
End Using
Return Nothing
End Function
End Class
Public Class Employee
Public Property emplName() As String
Get
Return m_empName
End Get
Set(value As String)
m_empName = value
End Set
End Property
Private m_empName As String
Public Property emplTitle() As String
Get
Return m_empTitle
End Get
Set(value As String)
m_empTitle = value
End Set
End Property
Private m_empTitle As String
Public Property empMail() As String
Get
Return m_empMail
End Get
Set(value As String)
m_empMail = value
End Set
End Property
Private m_empMail As String
Public Property mySource() As String
Get
Return m_mySource
End Get
Set(value As String)
m_mySource = value
End Set
End Property
Private m_mySource As String
Public Property mySAddress() As String
Get
Return m_mySAddress
End Get
Set(value As String)
m_mySAddress = value
End Set
End Property
Private m_mySAddress As String
Public Property mySIncome() As String
Get
Return m_mySIncome
End Get
Set(value As String)
m_mySIncome = value
End Set
End Property
Private m_mySIncome As String
|
|
|
|
|
Look at the sprInsertDisclsosures SP, does it define a "@name" parameter? If so look at the list of params you are adding to the command, none define @name.
You also have nested document.ready functions in your javascript, not sure that is going to work. Define a single document.ready and put everything you need into it.
|
|
|
|
|
Hi,
As stated in my last post, I tested the stored proc separately and it works a treat.
So, those params match exactly the ones you see in my code.
That's why I said it is showing deceitful error message.
Normally, that error would indicate that the @parameter is either not supplied or misspelled.
None of this is the case.
All of this struggle is because I am trying to create about 4 dynamic rows each with its own Add More button like the screenshot below:
Dynamic Rows[^]
I was able to do this in PHP with the help of Richard Deeming but management wants it done asp.net after those exhaustive efforts doing it in PHP.
I have scoured everywhere on the web looking for examples but I can find just one with one Add More Row button.
|
|
|
|
|
Computers don't make mistakes, but people do If I had a penny for every time a developer swore they hadn't misspelled something only for me to look and realise they had, or were looking at the wrong SP etc, I'd probably have £3.82.
|
|
|
|
|
Quote:
var contactdiv = '<tr class="data-contact-personm">' +
Is that a typo in your question? Based on the rest of your code, the class should be data-contact-person , without the trailing "m".
samflex wrote: parameter @name is required but not supplied
Are you absolutely sure the error message mentions the @name parameter? As F-ES Sitecore said, you're not passing a parameter called @name to the stored procedure, so if that's a required parameter, it would explain the error.
Alternatively, if the error is referring to one of the parameters you have defined, it's probably because one of the properties is Nothing . If you pass Nothing to the command parameter, the parameter will use its default value as defined in the stored procedure. If it doesn't have a default value, you'll get the "parameter not supplied" error.
The simplest solution would be to set a default value on the parameters of your stored procedure:
ALTER PROC sprInsertDisclsosures
(
@ename nvarchar(50) = Null,
@email nvarchar(200) = Null,
@title nvarchar(20) = Null,
@sname nvarchar(50) = Null,
@saddress nvarchar(max) = Null,
@sincome varchar(10) = Null
)
As
...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard,
First of all, just to make sure I have all my information out there, this is where I got the code i am currently using.
Add And Delete HTML Table Rows Dynamically Using ASP.NET[^]
I just modified to what it is right now.
No, that is not a typo.
Those are being called with the ajax call like:
function getAllEmpData() {
var data = [];
$('tr.data-contact-personm').each(function () {
var ename = $(this).find('.employeename01').val();
var etitle = $(this).find('.employeetitle01').val();
var email = $(this).find('.employeeemail01').val();
var alldata = {
'emplName': ename,
'emplTitle': etitle,
'empMail': email
}
data.push(alldata);
});
console.log(data);
return data;
}
Then
function getAllEmpData() {
var data = [];
$('tr.data-contact-person').each(function () {
function getAllEmpData() {
var data = [];
$('tr.data-contact-person2').each(function () {
etc.
In other words, any unique Add More button has its own row as in tr.data-contact-person. At least that's how I understand.
As for the error message, sorry it mentions @sname which is the alias for sourcename.
If I run these dynamic rows individually, they work just fine.
First instance, if I run the row that contains employeename, employeetitle and employeeincome, inserts correctly into the database.
Similarly, if I run the row that contains sourcename (@sname), sourceaddress, and sourceincome, it works just fine.
It is when I try to combine them that I get the error.
I suspect that ajax calls would not allow multiple INSERT statements.
As for the stored proc, I have it declared correctly. I wish that was the source of the error that I am having. I would have resolved it by now.
This is the stored proc just so you know:
CREATE PROCEDURE [dbo].[sprInsertDisclsosures]
@ename varchar(50),
@title varchar(50),
@email varchar(50),
@sname varchar(150),
@saddress varchar(100),
@sincome numeric(18,2)
as
BEGIN
SET NOCOUNT OFF;
INSERT INTO EMPLOYEES (employeeName, empTitle, email) Values (@ename,@title,@email);
declare @ID int
set @ID = SCOPE_IDENTITY()
if @@rowcount > 0
INSERT INTO SourceDetails (sourcename,sourceaddress, sourceincome,EmployeeID) Values (@sname, @saddress,@sincome, @ID);
END
If I test it from SSMS, it inserts records into Employees table, gets the last inserted ID and inserts into SourceDetails table. So, I don't think there is an issue here.
modified 8-Mar-17 14:51pm.
|
|
|
|
|
samflex wrote: No, that is not a typo.
Then there's a fundamental problem with your code. $('.data-contact-person') is not going to match a row with the class set to data-contact-personm - the trailing "m" makes it a completely different class name.
samflex wrote: As for the stored proc, I have it declared correctly.
As I said, if you pass a value of Nothing to a parameter without a default value, you'll get the exception.
Your parameters do not have default values. Therefore, if any property on your Employee class is Nothing , you'll get this error.
Also, it's not clear what you're trying to achieve. You have multiple employee rows, and multiple source rows, but there is no connection between the two.
You could have three employees and one source - what values are you going to post for the seconds and third employees?
Conversely, you could have three source rows and no employee rows, which would give you no parent record for the SourceDetails rows.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am trying to recreate in asp.net what we did in php where we have an employee information just once and then one or more soureces of income (sourcename, sourceaddress and source income).
I could not try to accomplish it with the same AngularJS code because asp.net as you know does not like duplicate control IDs.
Maybe I am using the code I posted incorrectly but the objective is to have a one to many relationship between employee and sourcedetails table and other tables as needed.
The code for employee is . $('.data-contact-personm') which matches this class ata-contact-personm unless I posted something different.
modified 8-Mar-17 15:04pm.
|
|
|
|
|
Well, I'm getting confused.
Your first message in this thread[^] has data-contact-person rows containing the source details, and data-contact-person2 rows containing spouse details. Your getAllEmpData function tries to read the spouse details from the source row, which isn't going to work.
Your message from four hours ago[^] has data-contact-personm rows containing the details of multiple employees, and data-contact-person rows containing the source details. Your getAllSourcepData attempts to read both employee and source details from the data-contact-person rows, which won't work.
Your Employee class seems to have a one-to-one relationship between the employee details and the source details. Your SQL tables seem to be set up for a one-to-many relationship between employees and sources, but your stored procedure only allows for a one-to-one relationship. Your description above indicates you want a one-to-many relationship.
If you just want one employee with multiple sources of income, why have you got code to add new employee rows?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, reset time. Sorry for the confusion.
Here is what I wanted to do initially.
Have an employee row with no option to add more rows.
Then have sourcedetails rows that allows users to click to add more rows.
Then have spouse rows that allows users to click to add more rows.
So essentially, one employee to one or many sources/spouse details.
That was the original intent.
Then I tested for just employee only.
That employee code you see now with the #emptable and #empdata is for the following:
<table id="emptable">
<thead>
<tr>
<th>Employee Name</th>
<th>Title</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr class="data-contact-person">
<td>
<input type="text" style="width:200px;" name="employeename" class="form-control employeename01" placeholder="Your name..." /></td>
<td>
<input type="text" style="width:200px;" name="employeetitle" class="form-control employeetitle01" placeholder="Your title..." /></td>
<td>
<input type="text" style="width:200px;" name="employeeemail" class="form-control employeeemail01" placeholder="Your email address..." /></td>
</tr>
</tbody>
</table><br /><br />
So you can see from here that I removed the
Add More button here. This way, employee can only be added once.
When I tested it, it inserted the records successfully.
Then I created one for sourcedetails and again it inserted successfully.
Finally, I created one for spousedetails and once again, it inserted into the database successfully.
Then I started to try to combine employee and sourcedetails.
If that worked, then i would have added SpouseDetails but it didn't work.
So, I started experimenting.
I think that's when the confusion came in.
|
|
|
|
|
Hi,
I have a site published on server. There are two gridview in one page, one redirect to a page where user fill the data in gridview and save it. The next gridview show the ids saved by user from first list. when the user click on the id it redirect to same page with data associated to that id. most of the time its working fine but sometime it gives an error of input string was not in a correct format. when i try to debug with my code it works fine and after I recycle the application pool of site it works fine.
|
|
|
|
|
It is impossible to guess what may be happening. All you can do is further debugging/logging to capture the data when it fails.
|
|
|
|
|
|
May be it is causing because of syntax error
|
|
|
|
|
Hi
I am developing the application in visual studio web forms
I am using the following Softwares
Microsoft Visual Studio Ultimate 2012
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.6.00081
Installed Version: Ultimate
Architecture and Modeling Tools 04940-004-0038003-02656
Microsoft Architecture and Modeling Tools
UML® and Unified Modeling Language™ are trademarks or registered trademarksof the Object Management Group, Inc. in the United States and other countries.
LightSwitch for Visual Studio 2012 04940-004-0038003-02656
Microsoft LightSwitch for Visual Studio 2012
Office Developer Tools 04940-004-0038003-02656
Microsoft Office Developer Tools
Team Explorer for Visual Studio 2012 04940-004-0038003-02656
Microsoft Team Explorer for Visual Studio 2012
Visual Basic 2012 04940-004-0038003-02656
Microsoft Visual Basic 2012
Visual C# 2012 04940-004-0038003-02656
Microsoft Visual C# 2012
Visual C++ 2012 04940-004-0038003-02656
Microsoft Visual C++ 2012
Visual F# 2012 04940-004-0038003-02656
Microsoft Visual F# 2012
Visual Studio 2012 Code Analysis Spell Checker 04940-004-0038003-02656
Microsoft® Visual Studio® 2012 Code Analysis Spell Checker
Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.
The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.
Visual Studio 2012 SharePoint Developer Tools 04940-004-0038003-02656
Microsoft Visual Studio 2012 SharePoint Developer Tools
ASP.NET and Web Tools 2013.1.41108
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Windows Azure Web Sites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure
ASP.NET Web Frameworks and Tools 2013.1 5.0.11113.0
For additional information, visit http://www.asp.net/
Crystal Reports for .NET Framework
Crystal Reports for .NET Framework
InstallShield Limited Edition
InstallShield. For more information visit the Flexera Software website at <http://www.FlexeraSoftware.com>. Copyright © 2015 Flexera Software LLC. All Rights Reserved.
NuGet Package Manager 2.8.60318.667
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
PreEmptive Analytics Visualizer 1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
SQL Server Data Tools 11.1.20627.00
Microsoft SQL Server Data Tools
While executing the application ,I am getting error
<b>The runtime has encountered a fatal error. The address of the error was at 0x6d46de47, on thread 0x15ac. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.</b>
Some times I am geting error.
<b>Accessviolation exception handled
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</b>
Please help me to fix the error.If not Is it necessary to reinstall asp.net?
Thanks and Regards
Chandran
|
|
|
|
|
Member 3080470 wrote: Please help me to fix the error That is not possible since no one can guess where it occurs or what your code is doing.
Member 3080470 wrote: If not Is it necessary to reinstall asp.net? Why do you believe that re-installing will fix a (probable) bug in your code.
The only way to resolve issues like this is to do extensive debugging and testing. You first need to identify where the error occurs and try to determine the circumstances that cause it.
|
|
|
|
|
Hello, i am in the process of learning ASP.net and ajax and i stumbled upon a issue. I made a web form application in which i have c# method for image upload and also a ajax function which is giving me issues.
this is my Default.aspx file:
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<a href="#" id="btnImg" onclick="uploadImg()" runat="server">UPLOAD</a>
</div>
</form>
<script>
function uploadImg(){
var formData = new FormData();
formData.append('FileUpload1', $("input[type=file]")[0].files[0]);
$.ajax({
type: "POST",
url: 'Default.aspx/imageUpload',
data: formData,
contentType: 'application/json; charset=utf-8',
success: function (data) {
alert(data);
}
});
}
</script>
and this is my Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
protected void imageUpload(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
Guid _fileNameRandom = Guid.NewGuid();
string _fileNameStr = _fileNameRandom.ToString();
FileUpload1.PostedFile.SaveAs(Server.MapPath("/Images/") + (_fileNameStr + fileName));
Response.Redirect(Request.Url.AbsoluteUri);
}
}
When i run it i get this error in the chrome console:
Quote: Uncaught TypeError: Illegal invocation
at e (jquery.min.js:4)
at xb (jquery.min.js:4)
at Function.r.param (jquery.min.js:4)
at Function.ajax (jquery.min.js:4)
at uploadImg (Default.aspx:33)
at HTMLAnchorElement.onclick (Default.aspx:21)
I assume i didnt do the ajax call correctly, but i cant figure out the problem as im farely new in this field.
|
|
|
|
|