|
Whenever you are posting back you can access Request.Form["ElementName"] to get what was the value before the form got posted. I did not understand the purpose of "linq statement that loads this dynamic panel". Can you tell me what is the architecture you are using. Is it Asp .Net Forms or MVC?
|
|
|
|
|
Hello,
I am novice programmer and require little assistance on the error, I am currently experiencing in the default.cs class below.
The name 'name' does not exist in the current context
default.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Data.SqlClient;
using System.Text;
using System.Collections.Generic;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static List<Data> GetData()
{
List<Data> dataList = new List<Data>();
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 0, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 78, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 82, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 425, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 79, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 80, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 57, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96.89, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 97, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 85, "Sept"));
return dataList.FindAll(r => r.ColumnName.Contains(name));
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
data.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class Data : Default
{
public string ColumnName = "";
public double Value = 0;
public string Date = "";
public Data(string name, double price, string date)
{
ColumnName = name;
Value = price;
Date = date;
}
}
Any help will be very much appreciated.
Thank you.
|
|
|
|
|
Your GetData method does not contain a variable or parameter called name , and your _Default class does not contain an accessible field or property called name . Therefore, the compiler doesn't know what you mean by "name", and cannot compile your code.
Assuming you want to pass the name you're looking for to the method, you need to introduce a parameter:
public static List<Data> GetData(string name)
{
...
}
"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 for your response. I really appreciate your help.
I manage to solve the compile error but my application now output blank webpage on the client-side. I can not seem to figure out why, but would I have to invoke callback method on the asp.button?
I am trying to build an application which can filter test data and display visual charts using google charts API.
default.aspx
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
</script>
<script type="text/javascript">
$('#Button1').click(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default.aspx/GetData',
data: "{name:'" + $("#SearchText").val() + "'}",
success:
function (response) {
drawVisualization(response.d);
}
});
})
function drawVisualization(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Date');
data.addColumn('number', 'Column Value');
for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].Date, dataValues[i].Value]);
}
new google.visualization.LineChart(document.getElementById('visualization')).
draw(data, { title: "" });
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Visual Search Testing with 'iFrame
</h2>
<asp:Label ID="Label1" runat="server" Text="Name/Ids"></asp:Label>
<asp:TextBox ID="SearchText" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" onclick="Button1_Click" />
<div id="visualization" style="width: 600px; height: 400px;"></div>
</asp:Content>
default.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Data.SqlClient;
using System.Text;
using System.Collections.Generic;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static List<Data> GetData(string name)
{
List<Data> dataList = new List<Data>();
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 0, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 78, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 82, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 425, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 79, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 80, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 57, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96.89, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 97, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 85, "Sept"));
return dataList.FindAll(r => r.ColumnName.Contains(name));
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
Any help would be very much appreciated.
Thanks
|
|
|
|
|
miss786 wrote: $('#Button1').click(function () {
Since you're using a master page, the client ID of Button1 won't be "Button1"; it will be something similar to "ctl00$MainContent$Button1".
If you're using ASP.NET 4.0, you can set the button's ClientIDMode[^] to Static , which will make sure that the client ID matches the server ID. If you're using an earlier version of ASP.NET, you'll need to find the correct ID, or use a different selector to find the button.
<asp:Button ID="Button1" runat="server" Text="Search" ClientIDMode="Static" />
You'll need to do the same for the SearchText textbox, since you reference it by ID:
<asp:TextBox ID="SearchText" runat="server" ClientIDMode="Static" />
miss786 wrote: $('#Button1').click(function () {
$.ajax({
...
});
})
You need to end the event handler function with return false; , otherwise the button will cause a post-back and the AJAX call won't run. You should also terminate the statement with a semi-colon.
$("#Button1").click(function(){
$.ajax({
...
});
return false;
});
miss786 wrote: data: "{name:'" + $("#SearchText").val() + "'}",
I'd strongly recommend using the built-in JSON.stringify[^] method to convert the parameters to a string. If you need to support IE7, you can use Douglas Crockford's JSON-js[^] script.
data: JSON.stringify({ name: $("#SearchText").val() }),
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
I really appreciate your help and time. I am sorry to inform, I am still unable to get the code to display any output on the client-side. I updated the code to your suggestion but I am still unable to find any errors in the debugging window of chrome developer tool (javascript).
default.aspx
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
</script>
<script type="text/javascript">
$('#Button1').click(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default.aspx/GetData',
data: "{name:'" + $("#SearchText").val() + "'}",
success:
function (response) {
drawVisualization(response.d);
}
});
return false;
})
function drawVisualization(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Date');
data.addColumn('number', 'Column Value');
for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].Date, dataValues[i].Value]);
}
new google.visualization.LineChart(document.getElementById('visualization')).
draw(data, { title: "" });
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Visual Search Testing with 'iFrame
</h2>
<asp:Label ID="Label1" runat="server" Text="Name/Ids"></asp:Label>
<asp:TextBox ID="SearchText" runat="server" ClientIDMode="Static"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" onclick="Button1_Click" ClientIDMode="Static" />
<div id="visualization" style="width: 600px; height: 400px;" runat="server"></div>
</asp:Content>
default.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Data.SqlClient;
using System.Text;
using System.Collections.Generic;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static List<Data> GetData(string name)
{
List<Data> dataList = new List<Data>();
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 0, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 78, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 82, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 425, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 79, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 80, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 57, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96.89, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 97, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 85, "Sept"));
return dataList.FindAll(r => r.ColumnName.Contains(name));
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
Any advice or suggestions would be very much appreciated.
Thank you so much for your time and help.
|
|
|
|
|
You've added a runat="server" to <div id="visualization" ...> . As a result, the client ID will not be "visualization"; it will be "ctl00$MainContent$visualization". As a result, you'll get a "container not defined" error from the Google script.
Either remove the runat="server" , or add ClientIDMode="Static" .
<div id="visualization" style="width: 600px; height: 400px;" runat="server" ClientIDMode="Static"></div>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hello Richard.
Thank you once again for your quick response. The code still does not work without the runat or with the clientIDMode tag. I also tired debugging the javascript but I am still unable to pin point where the code is falling.
Any advice would be most welcome.
Thank you so much.
|
|
|
|
|
The code works fine for me in Firefox 25, Chrome and IE10.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
Are you able to see the charts when submitting the search input? Would you mind me asking, what Visual studio you are using? I shall keep trying on my end.
Thank you so much for your help.
Kind regards
|
|
|
|
|
I'm using .NET 4.5.1 and a text editor. As long as you're using .NET 4.0 or higher, it shouldn't make any difference.
Are you seeing an empty chart? The String.Contains method[^] is case-sensitive, so if you type "clavs" you'll get no data back. If you want a case-insensitive search, try using the IndexOf method[^]:
[WebMethod]
public static List<Data> GetData(string name)
{
var dataList = new List<Data>();
...
return dataList.FindAll(r => r.ColumnName.IndexOf(name, StringComparison.CurrentCultureIgnoreCase) != -1);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi richard,
I really appreciate your support and time into this but for some strange reason, I am still seeing an empty chart whenever I trigger the search function on the client-side.
I changed the search code line from string to index function as you suggested, however still no result. I do not mind it being case sensitive or not. Whenever I type in "CLAVS 2007-1 M2A" into the search textbox, I am still getting a blank page.
Many Thanks
|
|
|
|
|
Strange - the code works fine for me. The only difference I can see is the base class for your Data class. Try removing it in case there's something odd with the serialization.
public class Data
{
public string ColumnName;
public double Value;
public string Date;
public Data(string name, double price, string date)
{
ColumnName = name;
Value = price;
Date = date;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello Richard.
Sadly, I am still unable to get the charts to display using the search criteria.
I also noticed, my data.cs file is under App_code, could this be issuing the blank charts on the client-side.
I really appreciate your help and time.
Thanks a million.
|
|
|
|
|
I doubt having the file under App_Code would make any difference.
Here's the entire file I'm using to test. I have a different master page, a different file name, and I'm not using a code-behind, but otherwise everything should be the same:
<%@ Page Language="C#"
MasterPageFile="~/_controls/Site.master"
Title="Chart Test"
%>
<%@ Import Namespace="System.Web.Services" %>
<script runat="server">
public class Data
{
public string ColumnName;
public double Value;
public string Date;
public Data(string name, double price, string date)
{
ColumnName = name;
Value = price;
Date = date;
}
}
[WebMethod]
public static List<Data> GetData(string name)
{
var dataList = new List<Data>();
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 0, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 78, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 82, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 425, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 79, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 80, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 57, "Oct"));
dataList.Add(new Data("CLAVS 2007-1 M2A", 77, "Oct"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("ACCDO 11A B", 2, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96.89, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 96, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 97, "Sept"));
dataList.Add(new Data("AELIS 2013-IRAR C", 95, "Oct"));
dataList.Add(new Data("AELIS 2013-IRAR C", 85, "Sept"));
return dataList.FindAll(r => r.ColumnName.IndexOf(name, StringComparison.CurrentCultureIgnoreCase) != -1);
}
</script>
<asp:content runat="server" contentPlaceHolderID="bodyContentPlaceholder">
<form runat="server">
<asp:Label ID="Label1" runat="server" Text="Name/Ids"/>
<asp:TextBox ID="SearchText" runat="server" ClientIDMode="Static"/>
<asp:Button ID="Button1" runat="server" Text="Search" ClientIDMode="Static" />
<div id="visualization" style="width: 600px; height: 400px;" runat="server" ClientIDMode="Static"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
</script>
<script type="text/javascript">
$('#Button1').click(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'chart.aspx/GetData',
data: "{name:'" + $("#SearchText").val() + "'}",
success:
function (response) {
drawVisualization(response.d);
}
});
return false;
});
function drawVisualization(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Date');
data.addColumn('number', 'Column Value');
for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].Date, dataValues[i].Value]);
}
new google.visualization.LineChart(document.getElementById('visualization')).
draw(data, { title: "" });
}
</script>
</form>
</asp:content>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dear Richard,
Apology for the late response. I am writing to sincerely thank you for helping me on this small task. I really appreciate your support and time into this post. After long struggle, I manage to find the cause of problem which was syntax errors in the #button.click javascript code.
$(document).ready(function () {
$('#Button2').click(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default.aspx/GetData',
data: "{name:'" + $("#SearchText").val() + "'}",
success:
function (response) {
drawVisualization(response.d);
}
});
return false;
});
});
Thanks a million for help. Have a great day.
Kind regards
|
|
|
|
|
Hey all,
I have got a problem with my buttons on my website, the buttons not always causing a postback, sometimes it works and sometime it does not, the buttons CausesValidation are set to false. I am not getting any javascript or server side errors.
Any Idea that will cause this issue?
modified 4-Nov-13 11:04am.
|
|
|
|
|
If you have CausesValidation set to True and you are not getting a postback, then it's possible that your validation controls are firing and not being displayed.
If you have validation controls set up make sure they are displayed properly to a ValidationSummary control. You could also set your CausesValidation property to False to by pass the validation and make sure it's hitting the server.
|
|
|
|
|
hey,
sorry, I meant to say my CauseValidation is set to false, I have take a look and there is no validation on that page.
|
|
|
|
|
Posting your code would help. Have you walked through it to make sure the code is following the proper path?
|
|
|
|
|
Hey Joshua,
I have solved the issue, it was my ComponentArt menu on my master page, I have read that it's a common issue with ComponentArt 2007 and framework 3.5, I decided to scrap the component and create my menu from scratch.
Thanks for your help
|
|
|
|
|
I am trying to change the password of users in Active Directory. My code is given below
------------------------------------------------------------------
DirectoryEntry entry = null;
entry = new DirectoryEntry("LDAP://10.8.128.101:389", "KSUSH\\" + username, password, AuthenticationTypes.Secure);
entry.UsePropertyCache = true;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(&(objectClass=user)(sAMAccountName=Temp7))";
DirectoryEntry entryUser = search.FindOne().GetDirectoryEntry();
entryUser.Invoke("ChangePassword", Old_Password, New_Password);
entry.CommitChanges();
----------------------------------------------------------------
When it execute the entryUser.Invoke line. it gives me the error given below
Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)
Please advice
tiyyob
|
|
|
|
|
hOW TO CREATE pc-phone,mobile dialer IN .NET PLATFORM
|
|
|
|
|
|
Can anybody tell me the Use of Delegate with real life example (program)?
You can e-mail me on theprofessional1992@gmail.com
|
|
|
|
|