Monday, 31 October 2016
Fix Error - A potentially dangerous Request.Form value was detected from the client ().
Watch this example on YouTube
Fix error
A potentially dangerous Request.Form value was detected from the client (CustomerFirstName="<B>").
to fix it add the following in Controller
[HttpPost]
[ValidateAntiForgeryToken]
[ValidateInput(false)]
public ActionResult Create(Customers2 customers2)
{
Fix Error - Non-invocable member 'System.Configuration.ConfigurationManager.ConnectionStrings' cannot be used like a method.
C# - Non-invocable member 'System.Configuration.ConfigurationManager.ConnectionStrings' cannot be used like a method.
Watch this example on YouTube
To fix it replace
System.Configuration.ConfigurationManager.ConnectionStrings("DefaultConnection").ToString();
With
System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
Watch this example on YouTube
To fix it replace
System.Configuration.ConfigurationManager.ConnectionStrings("DefaultConnection").ToString();
With
System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
Visual Studio - Fix issue - Intellisense not working
Watch this example on YouTube
To Fix it go to
Tools
Options
Text Editor
All Languages
General
make sure both
Auto list numbers
and
Parameter information are checked (not half checked)
To Fix it go to
Tools
Options
Text Editor
All Languages
General
make sure both
Auto list numbers
and
Parameter information are checked (not half checked)
Saturday, 29 October 2016
jQuery - Check if control is visible
watch this example on YouTube
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
if ($('#Button1').is(":visible")) {
alert('visible');
} else {
alert('not visible');
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Visible="true" Text="Button" />
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
if ($('#Button1').is(":visible")) {
alert('visible');
} else {
alert('not visible');
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Visible="true" Text="Button" />
</div>
</form>
</body>
</html>
jQuery - Check if control exists
Watch this example on YouTube:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
jQuery.fn.exists = function () { return this.length > 0; }
if ($('#Button1').exists()) {
alert('control exists');
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
jQuery.fn.exists = function () { return this.length > 0; }
if ($('#Button1').exists()) {
alert('control exists');
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
jQuery - same function used by multiple IDs (multiple controls)
Watch this example on YouTube
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#Button1, #TextBox1 , #CheckBox1').click(function () {
alert('control clicked');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" class='rb' runat="server" Text="Button" />
<asp:CheckBox ID="CheckBox1" class='rb' runat="server" />
<asp:TextBox ID="TextBox1" class='rb' runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#Button1, #TextBox1 , #CheckBox1').click(function () {
alert('control clicked');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" class='rb' runat="server" Text="Button" />
<asp:CheckBox ID="CheckBox1" class='rb' runat="server" />
<asp:TextBox ID="TextBox1" class='rb' runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
jQuery - How to get selected text of dropdownlist
Watch this example on YouTube:
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.rb').click(function () {
alert($("#DropDownList1").find("option:selected").text());
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>ONE</asp:ListItem>
<asp:ListItem>TWO</asp:ListItem>
<asp:ListItem>THREE</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" class="rb" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
jQuery - Get by ID with space
Watch this example on YouTube
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#Some\\ ID").val('dfasdfladsjfklasj');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Some ID" type="text" value ="oiuoui" />
</div>
</form>
</body>
</html>
jQuery - exclude all non numeric charachters in string
watch this example on YouTube
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var test = 'afda21432 afdasf 43243';
var res = test.replace(/\D/g, '');
alert(res);
});
</script>
</head>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var test = 'afda21432 afdasf 43243';
var res = test.replace(/\D/g, '');
alert(res);
});
</script>
</head>
Thursday, 27 October 2016
SQL Server - fix error - Incorrect syntax near '.'
Watch this example on YouTube
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.
To fix it replace
Select Customers.CustomerID Customers.CustomerFirstName from Customers
with (add comma)
Select Customers.CustomerID, Customers.CustomerFirstName from Customers
SQL Server - Fix error - Msg 208 Invalid object name
Watch this example on YouTube
Msg 208, Level 16, State 1, Line 1
Invalid object name 'Country'.
To fix it replace
Select * from Country
with
Select * from Test.dbo.Country
Msg 208, Level 16, State 1, Line 1
Invalid object name 'Country'.
To fix it replace
Select * from Country
with
Select * from Test.dbo.Country
Wednesday, 26 October 2016
VB.NET - Fix Error - Type 'Stream' is not defined.
Watch this example on YouTube
To fix it add
Imports System.IO
To fix it add
Imports System.IO
jQuery - Fix the following error: 0x800a138b - JavaScript runtime error: Cannot assign to a function result
Watch this example on YouTube:
Error:
0x800a138b - JavaScript runtime error: Cannot assign to a function result
To fix it replace
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.rb').click(function () {
$('#TextBox1').val()='';
$('#TextBox2').val()='';
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButton ID="RadioButton1" runat="server" class="rb" GroupName="test" />
<asp:RadioButton ID="RadioButton2" runat="server" class="rb" GroupName="test" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
With
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.rb').click(function () {
$('#TextBox1').val()='';
$('#TextBox2').val()='';
$('#TextBox1').val('');
$('#TextBox2').val('');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButton ID="RadioButton1" runat="server" class="rb" GroupName="test" />
<asp:RadioButton ID="RadioButton2" runat="server" class="rb" GroupName="test" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
Error:
0x800a138b - JavaScript runtime error: Cannot assign to a function result
To fix it replace
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.rb').click(function () {
$('#TextBox1').val()='';
$('#TextBox2').val()='';
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButton ID="RadioButton1" runat="server" class="rb" GroupName="test" />
<asp:RadioButton ID="RadioButton2" runat="server" class="rb" GroupName="test" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
With
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.rb').click(function () {
$('#TextBox1').val()='';
$('#TextBox2').val()='';
$('#TextBox1').val('');
$('#TextBox2').val('');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButton ID="RadioButton1" runat="server" class="rb" GroupName="test" />
<asp:RadioButton ID="RadioButton2" runat="server" class="rb" GroupName="test" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
Tuesday, 25 October 2016
Fix the following error - -'AsEnumerable' is not a member of 'System.Data.DataTable'.
Watch this example on YouTube
-'AsEnumerable' is not a member of 'System.Data.DataTable'.
to fix it add reference to System.Data.DataSetExtensions
-'AsEnumerable' is not a member of 'System.Data.DataTable'.
to fix it add reference to System.Data.DataSetExtensions
Monday, 24 October 2016
Fix Error - 'Compute' is not a member of 'System.Data.DataRow'.
Watch this example on YouTube
Fix Error 'Compute' is not a member of 'System.Data.DataRow'.
To fix it replace
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ds As DataSet = LoadData()
Dim query = From rec In ds.Tables(0).AsEnumerable() Select rec
If ds.Tables(0).Rows.Count > 0 Then
For Each r As DataRow In query
Dim s As Integer = IIf(r.Compute("Sum(Age)", "Valid = '1'") Is DBNull.Value, 0, r.Compute("Sum(Age)", "Valid = '1'"))
MessageBox.Show(s.ToString)
Next
End If
End Sub
Public Function LoadData() As DataSet
Dim ds As New DataSet
Dim dt As New DataTable
dt.Columns.Add("Valid")
dt.Columns.Add("Age", Type.GetType("System.Int32"))
dt.Rows.Add(New Object() {"1", 33})
dt.Rows.Add(New Object() {"2", 44})
dt.Rows.Add(New Object() {"1", 22})
dt.Rows.Add(New Object() {"1", 22})
ds.Tables.Add(dt)
Return ds
End Function
With
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ds As DataSet = LoadData()
Dim query = From rec In ds.Tables(0).AsEnumerable() Select rec
If ds.Tables(0).Rows.Count > 0 Then
For Each r As DataRow In query
Dim s As Integer = IIf(r.Table.Compute("Sum(Age)", "Valid = '1'") Is DBNull.Value, 0, r.Table.Compute("Sum(Age)", "Valid = '1'"))
MessageBox.Show(s.ToString)
Next
End If
End Sub
Public Function LoadData() As DataSet
Dim ds As New DataSet
Dim dt As New DataTable
dt.Columns.Add("Valid")
dt.Columns.Add("Age", Type.GetType("System.Int32"))
dt.Rows.Add(New Object() {"1", 33})
dt.Rows.Add(New Object() {"2", 44})
dt.Rows.Add(New Object() {"1", 22})
dt.Rows.Add(New Object() {"1", 22})
ds.Tables.Add(dt)
Return ds
End Function
Fix Error - Additional information: Invalid usage of aggregate function Sum() and Type: String.
Watch this example on YouTube
Error - Additional information: Invalid usage of aggregate function Sum() and Type: String.
To fix replace:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ds As DataSet = LoadData()
Dim query = From rec In ds.Tables(0).AsEnumerable() Select rec
If ds.Tables(0).Rows.Count > 0 Then
For Each r As DataRow In query
Dim s As Integer = IIf(r.Table.Compute("Sum(Age)", "Valid = '1'") Is DBNull.Value, 0, r.Table.Compute("Sum(Age)", "Valid = '1'"))
MessageBox.Show(s.ToString)
Next
End If
End Sub
Public Function LoadData() As DataSet
Dim ds As New DataSet
Dim dt As New DataTable
dt.Columns.Add("Valid")
dt.Columns.Add("Age")
dt.Rows.Add(New Object() {"1", 33})
dt.Rows.Add(New Object() {"2", 44})
dt.Rows.Add(New Object() {"1", 22})
dt.Rows.Add(New Object() {"1", 22})
ds.Tables.Add(dt)
Return ds
End Function
With
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ds As DataSet = LoadData()
Dim query = From rec In ds.Tables(0).AsEnumerable() Select rec
If ds.Tables(0).Rows.Count > 0 Then
For Each r As DataRow In query
Dim s As Integer = IIf(r.Table.Compute("Sum(Age)", "Valid = '1'") Is DBNull.Value, 0, r.Table.Compute("Sum(Age)", "Valid = '1'"))
MessageBox.Show(s.ToString)
Next
End If
End Sub
Public Function LoadData() As DataSet
Dim ds As New DataSet
Dim dt As New DataTable
dt.Columns.Add("Valid")
dt.Columns.Add("Age", Type.GetType("System.Int32"))
dt.Rows.Add(New Object() {"1", 33})
dt.Rows.Add(New Object() {"2", 44})
dt.Rows.Add(New Object() {"1", 22})
dt.Rows.Add(New Object() {"1", 22})
ds.Tables.Add(dt)
Return ds
End Function
Error - Additional information: Invalid usage of aggregate function Sum() and Type: String.
To fix replace:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ds As DataSet = LoadData()
Dim query = From rec In ds.Tables(0).AsEnumerable() Select rec
If ds.Tables(0).Rows.Count > 0 Then
For Each r As DataRow In query
Dim s As Integer = IIf(r.Table.Compute("Sum(Age)", "Valid = '1'") Is DBNull.Value, 0, r.Table.Compute("Sum(Age)", "Valid = '1'"))
MessageBox.Show(s.ToString)
Next
End If
End Sub
Public Function LoadData() As DataSet
Dim ds As New DataSet
Dim dt As New DataTable
dt.Columns.Add("Valid")
dt.Columns.Add("Age")
dt.Rows.Add(New Object() {"1", 33})
dt.Rows.Add(New Object() {"2", 44})
dt.Rows.Add(New Object() {"1", 22})
dt.Rows.Add(New Object() {"1", 22})
ds.Tables.Add(dt)
Return ds
End Function
With
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ds As DataSet = LoadData()
Dim query = From rec In ds.Tables(0).AsEnumerable() Select rec
If ds.Tables(0).Rows.Count > 0 Then
For Each r As DataRow In query
Dim s As Integer = IIf(r.Table.Compute("Sum(Age)", "Valid = '1'") Is DBNull.Value, 0, r.Table.Compute("Sum(Age)", "Valid = '1'"))
MessageBox.Show(s.ToString)
Next
End If
End Sub
Public Function LoadData() As DataSet
Dim ds As New DataSet
Dim dt As New DataTable
dt.Columns.Add("Valid")
dt.Columns.Add("Age", Type.GetType("System.Int32"))
dt.Rows.Add(New Object() {"1", 33})
dt.Rows.Add(New Object() {"2", 44})
dt.Rows.Add(New Object() {"1", 22})
dt.Rows.Add(New Object() {"1", 22})
ds.Tables.Add(dt)
Return ds
End Function
Subscribe to:
Posts (Atom)