|
required field validator is not working in this code
<%@ Page Language="VB" AutoEventWireup="false" codefile="~/Test.aspx.vb" Inherits="Test" %>
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<link rel="stylesheet" href="beml.css" />
<title>Welcome to BEML Limited</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="scriptmanger1" runat="server">
</asp:ScriptManager>
<div>
<table id="tblResume" runat="server" style="width: 325px;" cellpadding="0" cellspacing="0">
<tr>
<td style="background-image: url('images/title_bar.png'); padding-left: 10px; vertical-align: middle;
height: 40px;" class="subhead" align="left">
SUBMIT RESUME
</td>
</tr>
<tr>
<td style="border: 1px solid #F2F1F1; width: 325px;" align="center">
<table style="width: 96%;">
<tr>
<td class="mandatory" style="text-align: right; padding-right: 10px;" colspan="2">
All fields are mandatory
</td>
</tr>
<tr>
<td align="left" class="content">
Name*:
</td>
</tr>
<tr>
<td align="left" class="content">
<asp:TextBox ID="txtName" Width="225px" runat="server"
ValidationGroup="valEnquiry" CausesValidation="True" AutoPostBack ="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFName" runat="server" ControlToValidate="txtName" ErrorMessage="Please Enter Your Name" ValidationGroup="valEnquiry"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" style="padding-right: 10px;">
<asp:Button ID="btnRSend" CausesValidation="False" runat ="server" Text="Send" ValidationGroup="valEnquiry" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
I need help.
Thanks in advance
Have A Nice Day!
Murali.M
Blog
modified 27-Aug-14 16:14pm.
|
|
|
|
|
Your button, btnRSend has CausesValidation set to False which means when it is clicked the validators will not fire.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hello Experts,
We are building an app that allows users to make online reservations of our facility.
The code below is designed to allow users to perform a search by either specific date or by date range.
Users can also search by selecting a search option from the dropdownlist.
The way the code works currently, if user's search turns up nothing, then we get the following error message:
Object reference not set to an instance of an object.
Line 259: Dim lblcurrentpage As Label = DirectCast(gvrow.Cells(0).FindControl("CurrentPage"), Label)
Rather than the error message, w would like the code to work differently.
If user's search is successful, the results of his/her search is displayed.
If however, no data is found based on his or her search parameter, we would like to display one month's worth of results.
Is this possible?
Below is the current code we are using.
Private Sub showGrid()
' Set the value of the SearchString so it gets
SearchString = txtSpecificDate.Text
ViewSelect = Request("ViewBy")
If ViewSelect = "" Or ViewSelect = "Range" Then
ViewSelect = "Range"
Else
ViewSelect = "Specific"
End If
'Response.Write(ViewSelect)
'Response.End()
Dim strQuery As String
Dim strSearch As String
Dim receiveddate As String = txtSpecificDate.Text
Dim fromdate As String = txtFromDate.Text
Dim enddate As String = txtToDate.Text
' Dim dts As DateTime = DateTime.ParseExact(DateString, "MM/dd/yyyy", CultureInfo.InvariantCulture)
'Protect against SQL Injection
strSearch = Replace(receiveddate, "'", "''", 1, -1, 1)
fromdate = Replace(fromdate, "'", "''", 1, -1, 1)
enddate = Replace(enddate, "'", "''", 1, -1, 1)
receiveddate = DateTime.Today.ToString("MM/dd/yyyy")
fromdate = DateTime.Today.ToString("MM/dd/yyyy")
enddate = "12/31/2050"
' first: Do we use AND or OR between clauses in the WHERE?
Dim andors As String = ANDOR.SelectedValue
'Response.Write(andors)
'Response.End()
' and now build up the WHERE.
'First, initialize where just to make sure it has nothing prior to our search
Dim where As String
where = ""
Dim facilityT As DropDownList
facilityT = FindControl("DropDownList1")
If facilityT.SelectedValue <> "" Then
If where <> "" Then where = where & andors
where = " i.instructorName = '" & Replace(facilityT.SelectedValue, "'", "''") & "'"
End If
If ViewSelect = "Range" Then
If where <> "" Then where = where & andors
where = where & " CONVERT(VARCHAR(10), d.trainingDates, 101) >= '" & fromdate & "' AND CONVERT(VARCHAR(10), d.trainingDates, 101) < '" & (enddate) & "'"
End If
If ViewSelect = "Specific" Then
If where <> "" Then where = where & andors
where = where & " CONVERT(VARCHAR(10), d.trainingDates, 101) = '" & strSearch & "' "
End If
'Response.Write(where)
'Response.End()
strQuery = "SELECT L.LocationId," & _
"c.courseId, " & _
"c.coursename, " & _
"CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
" ELSE 'Available' END AS 'AvailableSeats'," & _
"d.dateid, " & _
" d.trainingDates, " & _
"d.trainingtime, " & _
" c.CourseDescription, " & _
" i.instructorName, " & _
"l.location " & _
" FROM tblLocations L " & _
" Inner Join tblCourses c on l.locationId = c.locationId " & _
" Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
" Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
" Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
" OUTER APPLY (Select Count(*) TakenSeats " & _
" FROM tblTrainings T " & _
" where(L.LocationId = T.LocationId) " & _
" AND c.courseId = t.courseId) TS where " & where
'Response.Write("DEBUG: " & strQuery & "<HR>")
'Response.End()
Dim cmd As New SqlCommand(strQuery)
Dim dt As DataTable = GetData(cmd)
If dt.Rows.Count = 0 Then
message.Text = "No Records Found"
End If
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Thanks a lot in advance for your assistance.
|
|
|
|
|
samflex wrote: 'Protect against SQL Injection
strSearch = Replace(receiveddate, "'", "''", 1, -1, 1)
fromdate = Replace(fromdate, "'", "''", 1, -1, 1)
enddate = Replace(enddate, "'", "''", 1, -1, 1)
Don't do that!
The only way to truly protect against SQL injection is to use a parameterized query. It's not even difficult:
Dim cmd As New SqlCommand("-placeholder-", conn)
Dim sb As New StringBuilder( *** BASE QUERY HERE, up to but not including the "where" keyword *** )
Dim andors As String = IF(ANDOR.SelectedValue = "OR", " OR ", " AND ")
Dim startedWhere As Boolean = False
If facilityT.SelectedValue <> "" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("i.instructorName = @InstructorName")
cmd.Parameters.AddWithValue("@InstructorName", facilityT.SelectedValue)
startedWhere = True
End If
If ViewSelect = "Range" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("d.trainingDates Between @FromDate And @EndDate")
cmd.Parameters.AddWithValue("@FromDate", Date.Parse(fromdate))
cmd.Parameters.AddWithValue("@EndDate", Date.Parse(enddate))
startedWhere = True
ElseIf ViewSelect = "Specific" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("d.trainingDates = @SpecificDate")
cmd.Parameters.AddWithValue("@SpecificDate", Date.Parse(strSearch))
startedWhere = True
End If
cmd.CommandText = sb.ToString()
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard
Ever since I started posting here, you have save me a lot - Thank you very much.
Does your solution include the core question that I have about presenting one month's data if user's search turns up nothing?
Also, I am not sure I understand the difference between
Dim cmd As New SqlCommand("-placeholder-", conn)
and
Dim sb As New StringBuilder( *** BASE QUERY HERE, up to but not including the "where" keyword *** )
I know the sqlcommand(..) is this:
SELECT L.LocationId," & _
"c.courseId, " & _
"c.coursename, " & _
"CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
" ELSE 'Available' END AS 'AvailableSeats'," & _
"d.dateid, " & _
" d.trainingDates, " & _
"d.trainingtime, " & _
" c.CourseDescription, " & _
" i.instructorName, " & _
"l.location " & _
" FROM tblLocations L " & _
" Inner Join tblCourses c on l.locationId = c.locationId " & _
" Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
" Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
" Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
" OUTER APPLY (Select Count(*) TakenSeats " & _
" FROM tblTrainings T " & _
" where(L.LocationId = T.LocationId) " & _
" AND c.courseId = t.courseId) TS where "
but I don't understand what goes into the stringbuilder(...)
modified 14-Aug-14 13:14pm.
|
|
|
|
|
The "-placeholder-" string in the SqlCommand constructor doesn't need to be changed. It's just there so that the command has some initial text which is obviously not a query. That text will be replaced later, once the full query has been built. (cmd.CommandText = sb.ToString() )
The *** BASE QUERY HERE ... *** part needs to be the base query, up-to but not including the final "where" statement:
Dim sb As New StringBuilder("SELECT L.LocationId," & _
"c.courseId, " & _
"c.coursename, " & _
"CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
" ELSE 'Available' END AS 'AvailableSeats'," & _
"d.dateid, " & _
" d.trainingDates, " & _
"d.trainingtime, " & _
" c.CourseDescription, " & _
" i.instructorName, " & _
"l.location " & _
" FROM tblLocations L " & _
" Inner Join tblCourses c on l.locationId = c.locationId " & _
" Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
" Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
" Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
" OUTER APPLY (Select Count(*) TakenSeats " & _
" FROM tblTrainings T " & _
" where(L.LocationId = T.LocationId) " & _
" AND c.courseId = t.courseId) TS")
The code then appends the relevant filters to the StringBuilder instance to produce the final query.
As for returning one month's data if the search doesn't find anything, you'll need to modify the If dt.Rows.Count = 0 Then ... End If block to issue a new query to return the default data. Something like:
If dt.Rows.Count = 0 Then
message.Text = "No matching records found."
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("@FromDate", Date.Today.AddMonths(-1))
cmd.Parameters.AddWithValue("@EndDate", Date.Today)
cmd.CommandText = "SELECT L.LocationId," & _
"c.courseId, " & _
"c.coursename, " & _
"CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
" ELSE 'Available' END AS 'AvailableSeats'," & _
"d.dateid, " & _
" d.trainingDates, " & _
"d.trainingtime, " & _
" c.CourseDescription, " & _
" i.instructorName, " & _
"l.location " & _
" FROM tblLocations L " & _
" Inner Join tblCourses c on l.locationId = c.locationId " & _
" Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
" Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
" Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
" OUTER APPLY (Select Count(*) TakenSeats " & _
" FROM tblTrainings T " & _
" where(L.LocationId = T.LocationId) " & _
" AND c.courseId = t.courseId) TS " & _
" where d.trainingDates Between @FromDate And @EndDate"
dt = GetData(cmd)
End If
You'll still need to modify the code which tries to find the "CurrentPage" label, in case the second query doesn't return any data either. There might not be a row, the row might not have any cells, or the cell might not contain a Label control called "CurrentPage"; any one of these things would cause your code to throw a NullReferenceException .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard,
Thank you very much sir.
Your code is so elegant. I hope to get close to where you are one day.
I have pretty much put all the pieces together but I think I have things a bit mixed up because first, I commented out some lines that are throwing errors.
Second, when the page loads, I start paging, it starts showing some weird lines.
Can you see what I am doing wrong?
Private Sub showGrid()
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("conString").ConnectionString)
' Dim strQuery As String
Dim cmd As New SqlCommand("-placeholder-", conn)
Dim sb As New StringBuilder("SELECT L.LocationId," & _
"c.courseId, " & _
"c.coursename, " & _
"CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
" ELSE 'Available' END AS 'AvailableSeats'," & _
"d.dateid, " & _
" d.trainingDates, " & _
"d.trainingtime, " & _
" c.CourseDescription, " & _
" i.instructorName, " & _
"l.location " & _
" FROM tblLocations L " & _
" Inner Join tblCourses c on l.locationId = c.locationId " & _
" Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
" Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
" Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
" OUTER APPLY (Select Count(*) TakenSeats " & _
" FROM tblTrainings T " & _
" where(L.LocationId = T.LocationId) " & _
" AND c.courseId = t.courseId) TS")
' Hard-code the acceptable values here:
Dim andors As String = If(ANDOR.SelectedValue = "OR", " OR ", " AND ")
Dim startedWhere As Boolean = False
If DropDownList1.SelectedValue <> "" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("i.instructorName = @InstructorName")
cmd.Parameters.AddWithValue("@InstructorName", DropDownList1.SelectedValue)
startedWhere = True
End If
If ViewSelect = "Range" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("d.trainingDates Between @FromDate And @EndDate")
cmd.Parameters.AddWithValue("@FromDate", Date.Parse(txtFromDate.Text))
cmd.Parameters.AddWithValue("@EndDate", Date.Parse(txtToDate.Text))
startedWhere = True
ElseIf ViewSelect = "Specific" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("d.trainingDates = @SpecificDate")
cmd.Parameters.AddWithValue("@SpecificDate", Date.Parse(txtSpecificDate.Text))
startedWhere = True
End If
cmd.CommandText = sb.ToString()
' Dim cmd As New SqlCommand(strQuery) 'This says cmd has already been declared
Dim dt As DataTable = GetData(cmd)
If dt.Rows.Count = 0 Then
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("@FromDate", Date.Today.AddMonths(-1))
cmd.Parameters.AddWithValue("@EndDate", Date.Today)
cmd.CommandText = "SELECT L.LocationId," & _
"c.courseId, " & _
"c.coursename, " & _
"CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
" ELSE 'Available' END AS 'AvailableSeats'," & _
"d.dateid, " & _
" d.trainingDates, " & _
"d.trainingtime, " & _
" c.CourseDescription, " & _
" i.instructorName, " & _
"l.location " & _
" FROM tblLocations L " & _
" Inner Join tblCourses c on l.locationId = c.locationId " & _
" Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
" Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
" Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
" OUTER APPLY (Select Count(*) TakenSeats " & _
" FROM tblTrainings T " & _
" where(L.LocationId = T.LocationId) " & _
" AND c.courseId = t.courseId) TS " & _
" where d.trainingDates Between @FromDate And @EndDate"
dt = GetData(cmd)
End If
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
|
|
|
|
|
I can't see anything obviously wrong with your code. The line you've commented out would generate a compilation error, because the cmd variable is already defined towards the start of the method.
samflex wrote: Second, when the page loads, I start paging, it starts showing some weird lines.
What do you mean by "weird lines"?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry to keep bothering you sir and thanks for your continued assistance.
There are actually two problems that I discovered upon further testing.
1, when I select a date range with good dates - meaning dates that exist on our db, it doesn't capture them.
Instead, it displays the month values we elected to display if user's search turns up empty.
Same happens when I perform a search with specific date.
So, for some reason, the parameters are not working.
As for what I meant by weird lines, when I first run the app, it displays for instance 3 pages with a text that says, Viewing page 1 of 3. when I click page2, the text now displays Viewing page 2 of 3. However, the paging doesn't change to page 2. It still has page 1 highlighted (based on color I used).
When I attempt to click that page 2 again, I get this:
First ... Prev LinkButton LinkButton LinkButton Label LinkButton LinkButton LinkButton Next ... Last
The original code I posted wasn't doing this. It was paging perfectly only problem was that I wanted it to display one month's data if user's selection doesn't exist on the DB.
|
|
|
|
|
What data-type are the dates stored as in your database? They should be either date , datetime2 , or something similar.
As for the paging, you haven't posted any code relating to that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
data-type is datetime.
Here is the code for paging (kind of long sorry). Markup not included because I am not sure you want to see it.
Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
GridView1.PageIndex = e.NewPageIndex
showGrid()
GridView1.DataBind()
End Sub
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
Dim gvrow As GridViewRow = GridView1.BottomPagerRow
Dim lblcurrentpage As Label = DirectCast(gvrow.Cells(0).FindControl("CurrentPage"), Label)
lblcurrentpage.Text = Convert.ToString(GridView1.PageIndex + 1)
Dim page As Integer() = New Integer(6) {}
page(0) = GridView1.PageIndex - 2
page(1) = GridView1.PageIndex - 1
page(2) = GridView1.PageIndex
page(3) = GridView1.PageIndex + 1
page(4) = GridView1.PageIndex + 2
page(5) = GridView1.PageIndex + 3
page(6) = GridView1.PageIndex + 4
For i As Integer = 0 To 6
If i <> 3 Then
If page(i) < 1 OrElse page(i) > GridView1.PageCount Then
Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("p" + Convert.ToString(i)), LinkButton)
lnkbtn.Visible = False
Else
Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("p" + Convert.ToString(i)), LinkButton)
lnkbtn.Text = Convert.ToString(page(i))
lnkbtn.CommandName = "PageNo"
lnkbtn.CommandArgument = lnkbtn.Text
End If
End If
Next
If GridView1.PageIndex = 0 Then
Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("LinkButton1"), LinkButton)
lnkbtn.Visible = False
lnkbtn = DirectCast(gvrow.Cells(0).FindControl("LinkButton2"), LinkButton)
lnkbtn.Visible = False
End If
If GridView1.PageIndex = GridView1.PageCount - 1 Then
Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("LinkButton3"), LinkButton)
lnkbtn.Visible = False
lnkbtn = DirectCast(gvrow.Cells(0).FindControl("LinkButton4"), LinkButton)
lnkbtn.Visible = False
End If
If GridView1.PageIndex > GridView1.PageCount - 5 Then
Dim lbmore As Label = DirectCast(gvrow.Cells(0).FindControl("nmore"), Label)
lbmore.Visible = False
End If
If GridView1.PageIndex < 4 Then
Dim lbmore As Label = DirectCast(gvrow.Cells(0).FindControl("pmore"), Label)
lbmore.Visible = False
End If
End Sub
Private Sub lb_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
GridView1.PageIndex = Convert.ToInt32(e.CommandArgument) - 1
End Sub
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Pager Then
Dim gvr As GridViewRow = e.Row
Dim lb As LinkButton = DirectCast(gvr.Cells(0).FindControl("p0"), LinkButton)
AddHandler lb.Command, AddressOf lb_Command
lb = DirectCast(gvr.Cells(0).FindControl("p1"), LinkButton)
AddHandler lb.Command, AddressOf lb_Command
lb = DirectCast(gvr.Cells(0).FindControl("p2"), LinkButton)
AddHandler lb.Command, AddressOf lb_Command
lb = DirectCast(gvr.Cells(0).FindControl("p4"), LinkButton)
AddHandler lb.Command, AddressOf lb_Command
lb = DirectCast(gvr.Cells(0).FindControl("p5"), LinkButton)
AddHandler lb.Command, AddressOf lb_Command
lb = DirectCast(gvr.Cells(0).FindControl("p6"), LinkButton)
AddHandler lb.Command, AddressOf lb_Command
End If
End Sub
End Class
|
|
|
|
|
There are two things missing from the top of your updated showGrid method which were in the original code:
SearchString = txtSpecificDate.Text
ViewSelect = Request("ViewBy")
If ViewSelect = "" Or ViewSelect = "Range" Then
ViewSelect = "Range"
Else
ViewSelect = "Specific"
End If
Also, since your dates are datetime , and your original code was only comparing the date part, you'll need to update the date filters:
If ViewSelect = "Range" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("(d.trainingDates >= @FromDate And d.trainingDates < DateAdd(day, 1, @EndDate))")
cmd.Parameters.AddWithValue("@FromDate", Date.Parse(txtFromDate.Text))
cmd.Parameters.AddWithValue("@EndDate", Date.Parse(txtToDate.Text))
startedWhere = True
ElseIf ViewSelect = "Specific" Then
sb.Append(If(startedWhere, andors, " WHERE "))
sb.Append("(d.trainingDates >= @SpecificDate And d.trainingDates < DateAdd(day, 1, @SpecificDate))")
cmd.Parameters.AddWithValue("@SpecificDate", Date.Parse(txtSpecificDate.Text))
startedWhere = True
End If
I can't see any obvious reason for the paging issues. I'd probably be inclined to use a DataPager control[^] rather than custom LinkButton controls, but if your code worked with the old version of the showGrid method, it should work just as well with the new version.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you so much Richard for your generous assistance.
The search by date range is working really good now.
For some reason, it wouldn't work until I changed this line:
sb.Append("(d.trainingDates >= @FromDate And d.trainingDates < DateAdd(day, 1, @EndDate))")
cmd.Parameters.AddWithValue("@EndDate", Date.Parse(txtToDate.Text))
to these lines:
sb.Append("(CONVERT(VARCHAR(10), d.trainingDates, 101) >= @FromDate And CONVERT(VARCHAR(10), d.trainingDates, 101) < @EndDate)")
cmd.Parameters.AddWithValue("@FromDate", txtFromDate.Text)
But the search by specific date is not working. It is still display the entire month which suggests it is not recognizing the date value I am passing as valid.
Don't worry, I will work this one out.
You are incredible inspiration to me on how to be patient.
Thank you very much sir.
Note: It is still exhibiting the odd behavior of displaying the weird links I posted earlier.
|
|
|
|
|
In my project using AJAX 4.5
ValidatorCalloutExtender and TextBoxWatermarkExtender controls used in project. following error occurred.
0x800a138f - JavaScript runtime error: Unable to get property 'UI' of undefined or null reference
I need help.
Thanks in advance.
Have A Nice Day!
Murali.M
Blog
|
|
|
|
|
It seems you missing some JavaScript code related to the Ajax Toolkit, however you will have to show us code/debug to see where and what exactly the problem...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
please find the code
<%@ Page Language="VB" MasterPageFile="~/privatemaster.master" AutoEventWireup="false"
CodeFile="InfoSettings.aspx.vb" Inherits="InfoSettings" Title="Information settings" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server">
Master Information Setting
|
Information in this page are included in various parts of the site. Please provide
accurate information.
| All fields marked * mandatory
|
<cc1:tabcontainer id="ClientTab" width="800px" runat="server"
="" activetabindex="0">
<cc1:tabpanel id="TabPanel1" runat="server" headertext="TabPanel1">
<headertemplate>
Company & Contact Info
<contenttemplate>
Information provided in this page will be included in Contact us page. The Company
name will be included in copyright declaration too.
|
<asp:panel id="pnlSaveCo" runat="server" defaultbutton="btnSaveCo">
Company Name*
| <asp:textbox id="txtName" runat="server" width="250px"
="" validationgroup="valContact">
<asp:requiredfieldvalidator id="RFCName" runat="server" controltovalidate="txtName"
="" display="None" errormessage="Enter Client Name" setfocusonerror="True" validationgroup="valContact">
<cc1:validatorcalloutextender id="VceRFCName" runat="server" targetcontrolid="RFCName"
="" enabled="True">
| Address*
| <asp:textbox id="txtAddress" runat="server" height="75px" textmode="MultiLine"
="" width="250px" validationgroup="valContact">
<asp:requiredfieldvalidator id="rfAddress" runat="server" controltovalidate="txtAddress"
="" display="None" errormessage="Enter Address" setfocusonerror="True" validationgroup="valContact">
<cc1:validatorcalloutextender id="vcexAddress" runat="server" targetcontrolid="rfAddress"
="" enabled="True">
| Contact Person*
| <asp:textbox id="txtContactPerson" runat="server" width="250px"
="" validationgroup="valContact">
<asp:requiredfieldvalidator id="rfContactPerson" runat="server" controltovalidate="txtContactPerson"
="" display="None" errormessage="Enter Contact persons name" setfocusonerror="True" validationgroup="valContact">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender7" runat="server" targetcontrolid="rfContactPerson"
="" enabled="True">
| Email Id (for display)*
| <asp:textbox id="txtEmail" runat="server" width="200px"
="" validationgroup="valContact">
<asp:checkbox id="cbEmailDisplay" runat="server"> Display email id online
<asp:requiredfieldvalidator id="RFEmail" runat="server" controltovalidate="txtEmail"
="" display="None" errormessage="Enter Email Id" setfocusonerror="True" validationgroup="Send">
<asp:regularexpressionvalidator id="REEmail" runat="server" controltovalidate="txtEmail"
="" display="None" errormessage="Enter valid email id" setfocusonerror="True" validationexpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" validationgroup="valContact">
<cc1:validatorcalloutextender id="VceRFEmail" runat="server" enabled="True" targetcontrolid="RFEmail">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender31" runat="server" targetcontrolid="REEmail"
="" enabled="True">
| Email Id *
For receiving online enquiries and contact us emails
| <asp:textbox id="txtEmailEnquiries" runat="server" width="200px"
="" validationgroup="valContact">
<asp:requiredfieldvalidator id="rfEmailenquiries" runat="server" controltovalidate="txtEmailEnquiries"
="" display="None" errormessage="Enter Email Id" setfocusonerror="True" validationgroup="Send">
<asp:regularexpressionvalidator id="reEmailenquiries" runat="server" controltovalidate="txtEmailEnquiries"
="" display="None" errormessage="Enter valid email id" setfocusonerror="True" validationexpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" validationgroup="valContact">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender5" runat="server" enabled="True" targetcontrolid="rfEmailenquiries">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender6" runat="server" targetcontrolid="reEmailenquiries"
="" enabled="True">
| Phone number*
| <asp:textbox id="txtPhone" runat="server" width="200px"
="" validationgroup="valContact">
<asp:requiredfieldvalidator id="rfPhone" runat="server" controltovalidate="txtPhone"
="" display="None" errormessage="Enter Phone number" setfocusonerror="True" validationgroup="valContact">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender1" runat="server" targetcontrolid="rfPhone"
="" enabled="True">
| Mobile number
| <asp:textbox id="txtMobile" runat="server" width="200px"
="" validationgroup="valContact"> <asp:checkbox id="cbMobile" runat="server"> Display Mobile number online
| <asp:button id="btnSaveCo" cssclass="mybutton" runat="server" text="Save"
="" validationgroup="valContact">
|
<cc1:tabpanel id="TabPanel2" runat="server" headertext="TabPanel1">
<headertemplate>
Search Engine optimization
<contenttemplate>
Search engine optimization is very essential for Web sites. Search engines primarily
give very high weightage for Title tag and Meta tags - Keywords & Description. Please
provide these to get good search engine visibility.
|
<asp:panel id="pnlSeo" runat="server" defaultbutton="btnSEO">
Title tag*
Recommended upto 80 characters
| <asp:textbox id="txtTitleTag" runat="server" width="450px" maxlength="300" validationgroup="Send">
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" controltovalidate="txtKeywords"
="" display="None" errormessage="Enter Keywords" setfocusonerror="True" validationgroup="Send">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender2" runat="server" targetcontrolid="rfKeywords"
="" enabled="True">
| Description*
Recommended upto 200 characters
| <asp:textbox id="txtDesc" runat="server" height="50px" textmode="MultiLine" width="450px">
<asp:requiredfieldvalidator id="rfDesc" runat="server" controltovalidate="txtDesc"
="" display="None" errormessage="Please enter Description" setfocusonerror="True" validationgroup="Send">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender3" runat="server" targetcontrolid="rfDesc"
="" enabled="True">
| Keywords*
Recommended upto 250 characters & upto 20 keywords
| <asp:textbox id="txtKeywords" runat="server" width="450px" height="50px" textmode="MultiLine" validationgroup="Send">
<asp:requiredfieldvalidator id="rfKeywords" runat="server" controltovalidate="txtKeywords"
="" display="None" errormessage="Enter Keywords" setfocusonerror="True" validationgroup="Send">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender4" runat="server" targetcontrolid="rfKeywords"
="" enabled="True">
| <asp:button id="btnSEO" cssclass="mybutton" runat="server" text="Save"
="" validationgroup="valSeo">
|
<cc1:tabpanel id="TabPanel3" runat="server" headertext="TabPanel1">
<headertemplate>
Smtp settings
<contenttemplate>
To receive emails from contact us and enquiry page, you will need to provide your
email id, smtp host (ip address) and its password. Please provide the same here.
|
<asp:panel id="pnlSmtp" runat="server" defaultbutton="btnSaveSmtp">
Email Id *
(for receiving enquiries and emails)
| <asp:textbox id="txtSmtpEmail" runat="server" width="200px"
="" validationgroup="valSmtp">
<asp:requiredfieldvalidator id="rfsmtpemail" runat="server" controltovalidate="txtSmtpEmail"
="" display="None" errormessage="Enter Email Id" setfocusonerror="True" validationgroup="valSmtp">
<asp:regularexpressionvalidator id="resmtpemail" runat="server" controltovalidate="txtSmtpEmail"
="" display="None" errormessage="Enter valid email id" setfocusonerror="True" validationexpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" validationgroup="Send">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender8" runat="server" enabled="True"
="" targetcontrolid="rfsmtpemail">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender11" runat="server" targetcontrolid="resmtpemail"
="" enabled="True">
| STMP Host (IP/domain)*
| <asp:textbox id="txtsmtphost" runat="server" width="200px" maxlength="300"
="" validationgroup="valSmtp">
<asp:requiredfieldvalidator id="rfsmtphost" runat="server" controltovalidate="txtsmtphost"
="" display="None" errormessage="Enter STMP host info" setfocusonerror="True" validationgroup="valSmtp">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender10" runat="server" targetcontrolid="rfsmtphost"
="" enabled="True">
| Password*
| <asp:textbox id="txtsmtppassword" textmode="Password" runat="server" width="200px"
="" validationgroup="valSmtp">
<asp:requiredfieldvalidator id="rfsmtppassword" runat="server" controltovalidate="txtsmtppassword"
="" display="None" errormessage="Enter Email Id" setfocusonerror="True" validationgroup="valSmtp">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender9" runat="server" enabled="True"
="" targetcontrolid="rfsmtppassword">
| <asp:button id="btnSaveSmtp" cssclass="mybutton" runat="server" text="Save"
="" validationgroup="valSmtp">
|
<cc1:tabpanel id="TabPanel6" runat="server" headertext="TabPanel1">
<headertemplate>
Logo
<contenttemplate>
Please add your Logo to replace the top InstaCMS logo.
|
<asp:panel id="pnlLogo" runat="server" defaultbutton="btnLogo">
<asp:image id="imgLogo" runat="server" imageurl="~/images/logo.png">
| Add / Change Logo
Will be resized to maximum of 100px width & 80px height proportionately
| <asp:fileupload id="fuLogo" runat="server">
| <asp:button id="btnLogo" cssclass="mybutton" runat="server" text="Save Image">
|
<cc1:tabpanel id="TabPanel5" runat="server" headertext="TabPanel1">
<headertemplate>
Home Image
<contenttemplate>
If you want to use your own image instead of the default image in the home page, please upload the image below. The image will be resized automatically if the width is over 600px or the height of the image is over 225px.
|
<asp:panel id="pnlImage" runat="server" defaultbutton="btnSaveImage">
<asp:image id="imgHome" runat="server" imageurl="~/images/home_image.jpg">
| Change Home page Image
Will be resized to maximum of 600px width & 300px height proportionately
| <asp:fileupload id="fuHomeImage" runat="server">
| <asp:button id="btnSaveImage" cssclass="mybutton" runat="server" text="Save Image">
|
<cc1:tabpanel id="TabPanel4" runat="server" headertext="TabPanel1">
<headertemplate>
Change password
<contenttemplate>
Please use the form below to change your control panel login password. The user
email id will be the same and cannot be changed by you. If you want to change it,
please contact InstaCMS.
|
<asp:panel id="pnlPassword" runat="server" defaultbutton="btnPassword">
Enter Password*
| <asp:textbox id="txtOldPassword" textmode="Password" runat="server" width="200px"
="" validationgroup="valPassword">
<asp:requiredfieldvalidator id="rfOldPassword" runat="server" controltovalidate="txtOldPassword"
="" display="None" errormessage="Enter Email Id" setfocusonerror="True" validationgroup="valPassword">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender15" runat="server" enabled="True"
="" targetcontrolid="rfOldPassword">
| Enter new password*
| <asp:textbox id="txtNewPassword" textmode="Password" runat="server" width="200px"
="" validationgroup="valPassword">
<asp:requiredfieldvalidator id="rftxtNewPassword" runat="server" controltovalidate="txtNewPassword"
="" display="None" errormessage="Enter Email Id" setfocusonerror="True" validationgroup="valPassword">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender12" runat="server" enabled="True"
="" targetcontrolid="rftxtNewPassword">
| Confirm new Password*
| <asp:textbox id="txtConfirmPassword" textmode="Password" runat="server" width="200px"
="" validationgroup="valPassword">
<asp:requiredfieldvalidator id="rfConfirmPassword" runat="server" controltovalidate="txtConfirmPassword"
="" display="None" errormessage="Enter Email Id" setfocusonerror="True" validationgroup="valPassword">
<cc1:validatorcalloutextender id="ValidatorCalloutExtender13" runat="server" enabled="True"
="" targetcontrolid="rfConfirmPassword">
| <asp:button id="btnPassword" cssclass="mybutton" runat="server" text="Save"
="" validationgroup="valPassword">
|
|
Have A Nice Day!
Murali.M
Blog
|
|
|
|
|
Hi,
I have this result of Guid :
d926ef0d-07df-3c5b-2246-12e061f71be1
Now i wanna to get the main string that was converted to this Guid?
Ans : the result for this guid is : "0000000000"
now My Question is :
what is the main string that converted to this GUID :
fd7bd272-f7e8-1e57-0a82-e15b79694d25
thanks in advanced!
|
|
|
|
|
A Guid is just a kind of 128bit number, nothing else. It is not at all a string.
If you have some strange algorithm for encoding or encrypting strings into a Guid, well, that's your own idea. We don't know how you do that. And consequently we cannot help you in reverting that strange process.
|
|
|
|
|
You may talk about a hash? Can you show us the code generates those 'GUID'...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
|
Thanks all!
But my question is how to decode ( i dont have encoding method) :
i got these from a website :
d926ef0d-07df-3c5b-2246-12e061f71be1 ------> "0000000000"
fd7bd272-f7e8-1e57-0a82-e15b79694d25 ------> "09130000000"
146b2bf5-fddb-5e68-0e9a-e5cdd19513dc ------> "0000000001"
4fb94dee-654f-55a5-5c94-71974b23fcd4 --------> "09130000001"
b69ff890-e528-a2fc-c011-8f31dcfe4794 ----> "09125395974"
f734f107-2d2c-b2e0-ed26-b92679d7cf68 ---> ???????????
any decoding algorithm ?
thanks in advanced!
|
|
|
|
|
hi
Dim job = From J In QryGen.co_jobs Where J.co_id = 1013 And J.industry_mas_id = 5 Order By J.job_id Descending Select New With {J.job_id}
this my query. in this I would like construct the query on runtime for where condition.
sometime need to include some other fields to where condition.
I need help.
Thanks in advance.
Have A Nice Day!
Murali.M
Blog
|
|
|
|
|
You are here on CodeProject since more that 10 years. How come it you haven't learned that you must not post your question into several places?
|
|
|
|
|
Hi I have 1 checkbox list in that one check box is mobiles and another one is Laptops.
If I check on mobile It wil brings all mobile from DB to My DAtList
If I check on laptop It wil brings all mobile from DB to My DAtList
Here id the code
.aspx
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged">
<asp:ListItem Value="0">Mobiles</asp:ListItem>
<asp:ListItem Value="1">Laptop</asp:ListItem>
</asp:CheckBoxList>
.aspx.cs
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
List<String> GetList = new List<string>();
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
GetList.Add(item.Value);
}
}
string str = "select * from ProductDetails where Producttype=@textInput";
SqlCommand cmd = new SqlCommand(str, con);
cmd.Parameters.Add(new SqlParameter("@textInput", 0));
for (int d = 0; d < GetList.Count; d++)
{
string text = GetList[d];
cmd.Parameters["@textInput"].Value = text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (count == 0)
{
dc = ds.Clone();
count++;
}
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i].ItemArray[0].ToString() != "NULL")
dc.Tables[0].ImportRow(ds.Tables[0].Rows[i]);
}
DataList1.DataSource = ds.Tables[0].DefaultView;
DataList1.DataBind();
}
}
}
|
|
|
|
|
|