AJAX :: Every Method Returns Null?
Feb 19, 2010had used ajax.method in my project & its working fine, but now Every Ajax.Method returns null now,
View 1 Replieshad used ajax.method in my project & its working fine, but now Every Ajax.Method returns null now,
View 1 Replies[Code]....
If I use $get, it does work as the expected functionality for $get. It is only $find that does not work.
Can anyone explain the problem?
I have a simple page containing a GridView control that generates thead and tbody tags after rendering. In my jQuery script, I have a line that reads this way:
$('#GridView1
thead').eq(0).html()
When the page loads for the first time, this script returns an objects and works well. But when I click a button and cause a postback, it returns null. By the way, the button changes the number of the rows returned from the data source (based on the value of a textbox) and updates the grid.
I have detailsview control with bound fields...some usingĀ Templatefields. I am trying to access values in those fields but i get nulls....i really dont know why..I am proving all my code....
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Projects.aspx.vb" Inherits="Projects" %>
<!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">
<head id="Head1" runat="server">
<title>Projects Statuses</title>
[code]....
I guess something might be getting messy with the mode changing event... a postback? But if i remove the databinding code, i get an error! why find control returns null??
I want to use multiple targets with my ModalPopUp extender. One of my buttons is set as target in the ModalPopup and the other one will use server-side code to show the ModalPopup.
This is my ModalPopup so far:
<msAjax:ModalPopupExtender ID="modalInform" runat="server"
BehaviorID="modalInform"
TargetControlID="btnSearchUsers" [code].....
Then I found this little tutorial on the ASP.NET AJAX site.But when I use $find("modalInform") in the pageLoad Javascript function (as defined in the tutorial at the bottom), I'm always getting a $find("modalInform") is null error.
This code is included in a usercontrol, the usercontrol is used in a ASPX page and this ASPX-page uses a MasterPage.
I've noticed that if I'm using
<%= modalInform.ClientID %>
I'm getting a different value then defined in my HTML-source (propably because of the MasterPage?).
will get to the matter quickly:
I have a new webpage "smile.aspx" with the web method "GetDate" that returns "current date as string".
I am using JQuery to make a Ajax call to that method, Right now i am using ASP.NET Version 2.0[.NET Framework 2.0,Visual Studio 2005].
The parameter returned by the Sucess function seem to return "undefined" .anyone Techhy, quick look at the ajax request code below will answer my problem.
[Code]....
I have a file upload page with an AsyncFileUpload control. When the user browses to the file the upload control pulls the file into memory. I then have an Upload button which fires the following code to save the file to a database.
I am finding that if files are over about 500KB then the FileBytes property of the control simply returns null. This happens on my server but when running the app locally it runs through fine.
I'm not handling the OnUploadCompleted event as I need to user to complete further information before committing the file to database.
I have this in my web.config: httpRuntime maxRequestLength="10000"/>
private void UploadDocument(int mietID)
{
if (Page.IsValid)
{
if (mietID > 0)
[Code]....
I have a very strange issue where SelectionList always returns NULL when i try check its Selected Item/Value. I Googled a bit and I found out that when i click the submit button, the page is being refreshed and the SelectionList is being data bound again so it will revert back to its original behavior.
Then i tried enclosing the binding code in the Page_Load event in a !IsPostBack but still when i try to access the Selected property it is null and an exception is thrown.
My code goes something like this... (the braces are not matched properly)
static SelectionList[] Symptoms;
static string UserID = "";
cmbSymptoms1,cmbSymptoms2,cmbSymptoms3 and cmbSymptoms4 are SelectionLists. I took them in to an array of SelectionList and then set the properties.
I had to make them static or else when i click the button to update, they will not retain their values.
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack == false)
{
//System.Diagnostics.Debug.WriteLine("Not IsPostBack");
if (Request.QueryString["id"] != null && Request.QueryString.ToString() != "")
{
//System.Diagnostics.Debug.WriteLine("id query string is not null :- " + Request.QueryString["id"]);
myclass = new Class1();...........
I am working on a mvc project, and having problem with json. i have created a demo project with list of colors
public JsonResult GetResult()
{
List<string> strList = new List<string>();
strList.Add("white");
strList.Add("blue");
strList.Add("black");
strList.Add("red");
strList.Add("orange");
strList.Add("green");
return this.Json(strList);
}
i am able to get these on my page, but when i try to delete one color, that is when i send the following using jquery
function deleteItem(item) {
$.ajax({
type: "POST",
url: "/Home/Delete/white",
data: "{}",
contentType: "application/json; charset=utf-8",
success: ajaxCallSucceed,
dataType: "json",
failure: ajaxCallFailed
});
}
the controler action public JsonResult Delete(string Color) {} Color always returns null, even if i have specified "/Home/Delete/white" in the url. i know i am doing something wrong or missing something, but not able to find out what.
I have a class library which has my LINQ doc in it. I added a stored procedure and I get the following in my .dbml.layout :
[Code]....
I include a reference to the dll of the class library to my web project and I get an error about value being returned as int where I am trying to put contents into a datalist or similar.
Code in class that calls this SP :
[Code]....
So I switched code to the following in my dbml.layout document :
[Function(Name="dbo.sp_newsSearch")]public IEnumerable<news_search_result> sp_newsSearch([Parameter(DbType="VarChar(200)")] string searchVal){IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), searchVal);return ((IEnumerable<news_search_result>)(result.ReturnValue));}
And included the following in an external file news_search_result.cs
[Code]....
But now I just get nothing returned. Is this wrong way of calling a SP via LINQ? or have I just put the wrong return type on my LINQ class?
I have a datalist with price label
<asp:label runat="server" ID="lblPrice" Font-Bold="true" Font-Size="Medium"> <%# DataBinder.Eval(Container.DataItem, "dProduct_price") %></asp:label>
i have used to find the control in my code but when i debug the value is null
Label price = (Label)e.Item.FindControl("lblPrice");
I have a DataTable for which a PrimaryKey constraint has been set to be a combination of an integer column and a datetime column. When I try to 'Find' a row by saying,
dtFunds.Rows.Find(iContainerIndex)
I get a null value. iContainerIndex has been defined as an object array of size 2 with the integer ID and date values in it.
When I set a breakpoint in my code, I see that the very same values are present in the datatable.
If I try to execute, DataTable.Select() method with the integer column filter, I get a result - but returns no result when called with the date column filter.
What am I doing wrong here? The very same DateTime value is present in the datatable.
why the below javascript code always returns null (mean alert) ?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div>
<telerik:RadComboBox ID="RadComboBox1" runat="server">
</telerik:RadComboBox>
</div>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
var combo = $find("<%= RadComboBox1.ClientID %>");
alert(combo);
</script>
</telerik:RadCodeBlock>
</form>
</body>
</html>
I have a linq to sql entity class in which I declared some DateTime fileds like this:
[Code]....
And this is how I fetch data form repository:
[Code]....
All non DateTime fields are filled properly but all datetimes are null.[Column(DbType = "smalldatetime")]
Why method FindControl() returns null on FormView until call DataBind(). After that it returns everything correctly? What workaround are there? Call DataBind() before first call of FindControl() ?
View 3 RepliesIt seemed to be the right place to post to.My problem is that when I try to read registry key, I get null value, even if it exists (regedit shows it exists).Application is windows service with Log On As Local System and registry key im trying to read is in HKEY_LOCAL_MACHINESOFTWAREClassesCLSIDOn my development machine (x64 win7) it works fine. But in live server (x64 windows server 2008 r2) I get NULL.ese operating systems should have similar policies or does Local System on server 2008 have any restrictions i should know about?
View 1 RepliesThis is what I'm trying to run:
[Code]....
When I browse to www.mysite.com/mycontroller/myaction/myid, everything works ok. But visiting www.mysite.com/mycontroller/myaction produces:Server Error in '/' Application.Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
I am following Chris Pietschmann's solution for theming in ASP.NET MVC.
One thing I have noticed is that the view name is not being retrieved from the ViewLocationCache on subsequent requests. I am using ASP.NET MVC 2.0 RC
When the following code is executed:
this.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, virtualPath);
and I hover over this.ViewLocationCache it just returns {System.Web.Mvc.NullViewLocationCache} - suggesting nothing was added?
I've been working for a long time with GridViews and DetailsViews, but yesterday I've come across a new scenario, which I quite do not understand.
I have a GridView with ImageButton (CommandName="Insert") which will change the mode of the DetailsView to Insert. Afterwards I'll look for a DropDownList inside that DetailsView and add some items dynamically. Works fine, but one first the first time I press that ImageButton. If I click on "Cancel" in the DetailsView and press the ImageButton again, the .FindControl() Method returns null.
I've created this sample: (To make it run in your Visual Studio, just bind a DataSource to the DetailsView, otherwise it will not be rendered)
Markup:
<asp:GridView ID="gvCategory" runat="server" OnRowCommand="gvCategory_RowCommand">
<Columns>
</Columns>
<EmptyDataTemplate>
[Code]....
I have also tried using a ItemTemplate, and not a InsertItemTemplate, but this results in the same. After using the ChangeMode-Method the DetailsView.CurrentMode == InsertMode. The only thing I can think of is, that the markup is already generated for the ItemTemplate and changing the Mode to InsertMode can't affect the rendered markup, or something like this.
I am facing an amazing problem in ASP.NET. I have a website with many sub directories. The sub directories have aspx and aspx.cs files but do not contain web.config files. I am using the web.config file of the parent directory for storing config items for the respective code files in sub directories. But when i m trying to read the web.config using ConfigurationManager.AppSettings[] with absolutely the correct keys, there's no value being returned. Most amazing fact is, this same code works fine in dev enviroment but not in staging.
View 1 RepliesWhen I run the code below, it works
int charId = int.Parse(Request.Params["charId"]);
EveFPT ctx = new EveFPT();
var theCharQuery = from a in ctx.tblChars
where a.id == charId
select new
{
Name = a.name,
CorpName = a.tblCorps.name,
AllianceName = a.tblCorps.tblAlliances.name
};
if(theCharQuery.Count() == 1)
{
var theChar = theCharQuery.First();
lblCharName.Text = theChar.Name;
lblCorpName.Text = theChar.CorpName;
lblAllianceName.Text = theChar.AllianceName;
}
However, If I the below
var theCharQuery = from a in ctx.tblChars
where a.id == charId
select a;
if(theCharQuery.Count() == 1)
{
tblChars theChar = theCharQuery.First();
lblCharName.Text = theChar.name;
lblCorpName.Text = theChar.tblCorps.name;
lblAllianceName.Text = theChar.tblCorps.tblAlliances.name;
}
the statement theChar.tblCorps always returns null.
I'm using a very simple Ldap query in my asp.net mvc 2.0 site:
String ldapPath = ConfigReader.LdapPath;
String emailAddress = null;
try
{
[code]....
I'm running it under the default app pool.
I get a 404 error when I navigate to the following URL using the route below:
http://localhost:53999/properties/
However, all the following are correctly routed to the List action in my controller:
http://localhost:53999/properties/usa/new-york/manhattan/12
http://localhost:53999/properties/usa/new-york/manhattan
http://localhost:53999/properties/usa/new-york
http://localhost:53999/properties/usa [Code]....
In PropertiesController.cs: [Code]....
It looks like it should just go to the default controller/action,
I have a gridview. In the rowupdating event, the txtbox returns null. I have enabled viewstate for the gridview. But still it does not work. I have made this in Kentico.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" EnableModelValidation="True"
OnRowUpdating="GridView1_RowUpdating" >
<Columns>
<asp:CommandField ShowDeleteButton="True" CausesValidation="false" ShowEditButton="True"
ControlStyle-Width="100px" />
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Name" SortExpression="name">
<ItemTemplate>
<asp:Label ID="lblRegionName" runat="Server" Text='<%# Bind("name") %>' Width="200px"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="EditRegionName" OnTextChanged="EditRegionName_Updated"
Text='<%# Bind("name") %>' Width="200px" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server" ID="InsertRegionName" Text='' Width="200px" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Archived" SortExpression="IsArchive">
<ItemTemplate>
<asp:CheckBox ID="lblArchive" Enabled="false" runat="Server" Checked='<%# DataBinder.Eval(Container.DataItem, "archived") %>'
Width="100px" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox runat="server" OnCheckedChanged="EditArchive_CheckedChanged" ID="EditArchive"
Width="100px" />
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox runat="server" ID="InsertArchive" Checked="false" Width="100px" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="btnHistory" runat="server" Text="History"></asp:LinkButton>
<ajaxToolkit:ModalPopupExtender OkControlID="OkButton" ID="ModalPopupExtender1" runat="server"
BackgroundCssClass="modalBackground" TargetControlID="btnHistory" PopupControlID="Panel1" />
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none">
<div>
<iframe frameborder="0" src="/CMSWebParts/MSM/RoundTableAfrica/Beheer/History.aspx?id=<%# DataBinder.Eval(Container.DataItem, "id") %>"
width="500px" height="100%" scrolling="no"></iframe>
<br />
<asp:Button ID="OkButton" runat="server" Text="OK" CausesValidation="false" Width="50" />
</asp:Panel>
</div>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btnInsert" runat="server" Text="Insert" OnClick="Insert_Click" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
Region Name:<asp:TextBox runat="server" ID="NoDataRegionName" />
Archived:<asp:CheckBox runat="server" ID="NoDataIsArchive" />
<asp:Button runat="server" ID="NoDataInsert" CssClass="contentButton" Text="Insert"
OnClick="Button1_Click" />
</EmptyDataTemplate>
</asp:GridView>
<asp:Button runat="server" ID="Add" Text="Add" OnClick="Add_Click" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RTAConnectionString%>"
ProviderName="System.Data.SqlClient" SelectCommand="select * from [spiderwebs_region] order by name "
UpdateCommand="UpdateRegionWithHistory" UpdateCommandType="StoredProcedure"
DeleteCommand="DeleteRegionWithHistory" DeleteCommandType="StoredProcedure" OnInserting="Sqldatasource1_Inserting"
OnInserted="Sqldatasource1_Inserted" InsertCommand="InsertRegionWithHistory"
InsertCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="action_time" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="content_type_id" Type="Int32" />
<asp:Parameter Name="object_repr" Type="String" />
<asp:Parameter Name="action_flag" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataBind();
}
protected void GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
int index = e.RowIndex;
GridViewRow currentrow = ((GridView)sender).Rows[index];
TextBox txtbox = (TextBox)currentrow.FindControl("EditRegionName");
CheckBox isarchive = (CheckBox)currentrow.FindControl("EditArchive");
e.NewValues["name"] = txtbox.Text;
e.NewValues["archived"] = isarchive.Checked;
GridView1.EditIndex = -1;
GridView1.DataBind();
}
I have a UserControl that has some controls inside. I want to refer those controls after, in another postback. But when I try to get them the Controls property of my controls returns null. I'm working on vs2008.
Here is the sample code:
[code]....