Object Reference Lost After Post Back - __EVENTTARGET GridVieww And LinkButton
May 30, 2010
I have a GridView and a LinkButton control. I click the LinkButton control and loose the object reference to both objects after post back. I want to be able to get the command arguments from the link button and then be able to get a reference to the gridview control to determine which page index to set the gridview. I have been able to get the __EventTarget property to reference the object that was called but Im not able to reference that object.
The Item is applied for GridViewRow. This GridView is in a UpdatePanel, when I click a button to do a Ajax Post Back the CSS applied for the GridViewRow is useless (IE 6 only).
I have used update panel and in that update panel I have kept ASP Table control in which I am creating rows dynamically which in turn contains 1 dropdown lists and 3 text boxes. My problem is that after partial postback text boxes and dropdown list are found but text property of text boxes is showing empty and dropdown list's selected value is set to the first record in that box. I have also stored entire table in session and retrieve it in(!isPostBack) condition at page_load event.
part of my .aspx page is as below
[code]....
I want to add one row on every addRowTbn click event there by retaining previous rows.
I have 2 pages in my project (that are causing the problems). My default page has a FormView that for some reason will not let me access page events, such as buttons for instance, in code behind. They show up fine on page but are not visible in the page events drop down in code behind. We are using a work around for that.
The main issue now is that on my ViewTaxes.aspx page I need to get the values of some of the text boxes from the default page by Control Number, i.e. whatever record is being viewed on default page when you click the ViewTaxes link button, much more detailed information about that particular record is displayed on ViewTaxes. If on ViewTaxes I use a SELECT * statement I can access the ViewTaxes page when I click the button. We, of course, need to filter the data displayed by ControlNumber. When I add a WHERE clause to the DS on ViewTaxes page and click linkbutton on the default page I get an Object Reference error. This error seems to have something to do with a group of textboxes that are displayed via Session in codebehind. Values from default page being displayed in one section of ViewTaxes page. The error when thrown always points to Session("Owner1") = txtCust1.Text. If that code is removed then error will go to next Session variable, an so on.
I should also point out that both pages worked fine, no problems at all, using a test MySql table. We recently migrated the actual table that will be used from an Access database and replaced the test table. Can't find any spelling errors or anything of that nature. There are some Null fields in this database but it is set to allow Nulls.
Here I want when click on linkbutton it change text's color so I wrote below code:
protected void c(object sender, EventArgs e) { this.GetCustomersPageWiseMC(1, (sender as LinkButton).CommandArgument); BindDataListD(DLclassC, "classTI_documentry"); DataListItem item = (DataListItem)(sender as LinkButton).NamingContainer; foreach (DataListItem dlItems in DLclass.Items)
[Code] ....
For Linkbtnclass_Click it worked correctly and when I click on linkbutton it change color but for LinkbtnclassC_Click when I click on linkbutton it make this error:
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.
Source Error:
Line 537: { Line 538: LinkButton lb1 = dlItems1.FindControl("Linkbtnclass1") as LinkButton; Line 539: lb1.ForeColor = ColorTranslator.FromHtml("#646464"); Line 540: } Line 541:
i have 10 list boxes in my aspx page for all 10 list boxes same function is using for some buttons i want to add listbox data to grid can you java script code shown below
f[code]....
i tried a javascript above code to move items between listbox using html input button problem when i trying to save listbox.items.count giving 0 can anyone tell me why this happening and also when post back occurs listbox items lost.
programmatically creating an ImageButton. i am getting an error, object reference not set to an instance of an object. The application is not finished so most of it will not work but my question is about the ImageButton only. The application can be viewed at:
as you can see in the C# code below. i create an ImageButton imgBtn and attach the properties to it but when i click on the ImageButton from the calendar, it gives me an error. at the moment, clicking on the imgbtn is only suppose to write something to the trace. i am not sure whether or not the fact that the imgbtn is created inside a for loop has anything to do with it.
We have a Static class that 's called CData in our asp.net c# app.It handles all the data layer CRUD functionality on our pages.
Problem is, were are losing the intellisense reference in our pages to it.For example: we would expect to type CData.(dot) and have a list of methods and properties available to us.
Nope. Not there.
I kind of thought it was because the file was getting too long at 3000 lines of code, since some other static classes were working ok.
So then I thought that I'd try wrapping the CData Class in a namespace. That worked, but of course I had to put an include statement of the top of each page that's using CDATA, also, now some of the other developers are getting errors in there pages complaining about missing methods that are in CDATA, but their pages are not seeing.
I have two Repeater controls, each hosted in a user control. Both user controls are contained in the same aspx page. Only one User Control is visible at any one time. The repeaters are comprised of checkboxes, and text boxes for user input.
The aspx page is configured with an Ajax ScriptManager; and contains several Ajax UpdatePanels. These UpdatePanels result in partial page post backs when text is changed in a textbox control in controls on the aspx page (this is not the behaviour for the Repeaters in the User Controls). Through use of several AsyncPostBackTriggers, various controls contained in the other UpdatePanels on the page have their content refreshed in response to the partial page post backs they are configured be notified about.
Depending on a radio button group selection, I set the visible property to true or false - as appropriate for the User control containing a repeater control. The Repeater control is then populated with data using databinding. All of this works.
However, when the Submit button is clicked, the Repeater control contains no data.
Given that I am not dynamically adding the Controls containing the Repeater controls (but using Visible true / false). I would have thought that the State of the fields and the data in the visible control would be preserved during the post back.
The User Controls are contained within the UpdatePanel that contains the Submit Button.
I have explicitly Enabled View state without any effect.
Am I correct in assuming that I should not have to do any explicit handling of data changes the user makes (via client side script and manipulation of an Data Structure Representing the Repeater Data); and the View State should maintain the data I need to access on the server when submitted?
I do not believe that it is the User Control visible state changes that are causing the issue because when the page is initially loaded on of the User controls is populated with dummy rows (so it displays).
I am suspicious that because the visible state of the controls is changed during partial page post back, that the Page View State ends up with no knowledge of the User Control and therefore cannot track its data (or changes).
I have four textbox and a button in my page. After filling the textbox. When the user click save button. A loading image should be displayed. User should not feel that the page is postback to the server,Some thing like in facebook loading image.
Being new to ASP.NET I have run into trouble building my own Whack-a-mole program. I think my problem comes from using Buttons, which by themselves send post backs to the server, making the software unusable. The looks are in place, making new buttons show up in the grid, in different places by random. However, when a button is pushed - the score doesn't change (which I feel is strange).
Not so strange is that the Button doesn't work since it sends post back to the server - reloading the UpdatePanel. I think I should use a different controller like the CheckBox and style it hard using CSS (which isn't a problem). Is this the correct way to go, or should I make use of JavaScript AJAX instead?
Note to self: This technique shouldn't be used in a public application since it put too much unwanted pressure on the web server.
in my default.aspx page i have a dropdown List and a textbox with a submit button below that there are 2 listbox... and the dropdown list holds the names of the listbox
my logic here is to select an item from the dropdown list and put some text in the text box and submit the form which will add an item to the listbox selected.. but when i do this i get an error saying Object reference not set to an instance of an object. i tried to figure out the problem and found that when i remove the reference to the Site Master Page it works fine and when i undo and apply my reference back to the Site Master Page i get the same error.
I am using grid view as mentioned below, it is giving me error "object reference not set", but if comment allowpaging and pagesize lines, it works. let me know whats wrong I am doing?
I searched google and found asynchronise post back trigger is used if we want update panel to post back on some event of control if it is out side the update panel. Than what is purpose of post back trigger ?
I have a very odd and disconcerning problem. Just recently a page where I have 1 textbox and a buttoon has ceased to work.
When I look at the post coming into the PageLoad, the pageType is "POST", but the Page.IsPostBack is false!! and the textbox (which had content) is empty.
I have stripped all AJAX script out, so I have a very vanilla page (in a master page) being served.
The pages is
[Code].... [Code]....
The page is "POST", but isPostback is false[Code]....
When a Link button I have in my gridview that expands the table to show a nested gridview i lose all the row colors that i get from this function. What I need is a way to call the function when the link button is clicked.
<script type="text/javascript"> $(document).ready(function () { $("#<%=GridView1.UniqueID%> tr").each(function () { var status = $(this).children('td:eq(6)').text(); if (status == 'OK') { $(this).children('td').css({ "background-color": "lightgreen" }); } else if (status == 'XL') { $(this).children('td').css({ "background-color": "RED" }); } else if (status == 'CL') { $(this).children('td').css({ "background-color": "YELLOW" }); } }) }); </script>
I am working on converting a project from C# to VB and am facing this weird issue. 1 page cannot compile and I get the reference error, but the weird thing is that the compiler shows the error as coming from ASP.NET generated code. Visual Studio shows me that error is coming from my ASPX page. I cannot seem to figure out why or where this error is occuring. Also if I take the inherits attribute out I don't get the compilation error. The code in aspx page is below:
I work on a HR application for Internal people.One of my staff member is caliming that he applied for a job, but we do not have any entry in the database for applicants and no error in Log4net.
The staff member calims that he clicked on the Apply Button. And when we checked the IIS log we found one entry by that user in the IIS event viewer. Now how to determine if the person actaully clicked the apply now button or not.This is a serous issue for us as he is very upset as the Advertising for that position is taken off and he cannot apply now.
How to investigate? Also does IIS logs all POSTS and GET Requests?ur system Admin passed me an error log from the event viewer.Which is something like this:
2010-05-05 00:28:57 172.10.12.30 POST /HROnline/Recruitment/Apply.aspx rk=579&pid=0 8600 INTERNALMIISNY 172.20.102.50 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729
http://www.somepage.com/main.aspx. In this page, when I click on a link it takes me to a page http://www.somepage.com/cental.aspx?cid=200. So in the cental.aspx.cs page I did the following in the page load:
if(request.querystring["comp"].tostring() != null) { //do some thing [code].....
So I got an error like: object reference not set to an instance of reference.My problem is, I am using the same page. So when I go from some page, I will have "comp". but other times not. So when there is no "comp", how do I handle it in request.querystring?