TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tom smith
NA
17
0
Prevent update of Listview based upon javascript validations
Jul 9 2012 5:19 AM
Hi All,
I have a listview control with edit/insert templates. I am using javascript to validate entries for the listview. While the javascript function returns correct true or false values, i want to prevent the listview to be updated if the javascript validation returns a false value. I dont want to use requiredfield validation controls, as i am using a master page also and it tends to cause me issues.
My javascript function is as below:
<script type="text/javascript">
var bProceedFurther = false;
function ValidateBillableYN(id) {
var tbl = id;
var e = tbl.value;
if (e != 'Y' && e != 'N') {
bProceedFurther = false;
return false;
}
else {
return true;
}
if (e == '') {
bProceedFurther = false;
return false;
}
else {
return true;
}
}
function ValidateJobDescription(id) {
var tbl = id;
var e = document.getElementById(tbl).value;
if (e.value == '') {
bProceedFurther = false;
return false;
}
else {
document.getElementById("<%=lblErrorMessage.ClientID%>").innerHTML = "";
return true;
}
}
function ValidateGrid() {
if (ValidateBillableYN(document.getElementById("ContentPlaceHolder1_lvwEstimateJobDetails_txtUpd_Billable_0")) == false) {
document.getElementById("<%=lblErrorMessage.ClientID%>").innerHTML = "* Billable Field Should Either Be Y Or N Only";
document.getElementById(tbl).focus();
return false;
}
if (ValidateJobDescription(document.getElementById("ContentPlaceHolder1_lvwEstimateJobDetails_txtUpd_JobDescription_0")) == false) {
document.getElementById("<%=lblErrorMessage.ClientID%>").innerHTML = "* Job Description Field Cannot Be Blank";
document.getElementById(tbl).focus();
return false;
}
else {
document.getElementById("<%=lblErrorMessage.ClientID%>").innerHTML = "";
return true;
}
}
</script>
Codebehind:
Protected Sub lvwEstimateJobDetails_ItemCommand(sender As Object, e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles lvwEstimateJobDetails.ItemCommand
Dim txtItemSerialNo As New TextBox
Dim txtJobDescription As TextBox
Dim txtBillable As TextBox
Dim strSQL As String
If (e.CommandName = "Insert") Then
txtItemSerialNo.Text = GetNextItemSerialNo(txtJobNumber.Text)
MsgBox("Next No. = " + txtItemSerialNo.Text)
txtJobDescription = e.Item.FindControl("txtJobDescription")
txtBillable = e.Item.FindControl("txtBillable")
strSQL = "INSERT INTO [EstimateJobs] ([EstimateNumber],[JobDescription],[Billable],[ItemSerialNumber]) VALUES ('" + txtJobNumber.Text + "', '" + txtJobDescription.Text + "', '" + txtBillable.Text + "', " + txtItemSerialNo.Text + ")"
MsgBox(strSQL)
sqlDS_EstimateJobDetails.InsertCommand = strSQL
ElseIf (e.CommandName = "Update") Then
txtItemSerialNo = e.Item.FindControl("txtUpd_ItemSerialNumber")
txtJobDescription = e.Item.FindControl("txtUpd_JobDescription")
txtBillable = e.Item.FindControl("txtUpd_Billable")
strSQL = "UPDATE [EstimateJobs] SET [JobDescription]='" + txtJobDescription.Text + "', [Billable]='" + txtBillable.Text + "' WHERE EstimateNumber='" + txtJobNumber.Text + "' AND ItemSerialNumber='" + txtItemSerialNo.Text + "'"
MsgBox(strSQL)
sqlDS_EstimateJobDetails.UpdateCommand = strSQL
ElseIf (e.CommandName = "Delete") Then
txtItemSerialNo = e.Item.FindControl("txtUpd_ItemSerialNumber")
strSQL = "DELETE FROM [EstimateJobs] WHERE EstimateNumber='" + txtJobNumber.Text + "' AND ItemSerialNumber='" + txtItemSerialNo.Text + "'"
sqlDS_EstimateJobDetails.DeleteCommand = strSQL
End If
End Sub
Reply
Answers (
0
)
i want to get key press event in asp.net as similar in window application...Pls tell how to override textbox properties??
Can anyone please show me how to store and retrieve binary Image with data in datalist