Fórmulas e Cenas

Object Reference Not Set to an Instance of an Object

  Home  |   Contact  |   Syndication    |   Login
  44 Posts | 0 Stories | 13 Comments | 0 Trackbacks

News

Archives

Post Categories

Links

Asp.Net

When you are inserting into a table using entity framework, on rare occasions you might get the following error: {System.Data.OptimisticConc... Store update, insert, or delete statement affected an unexpected number of rows (0) This happened to me because of an "instead of INSERT" trigger that was active on the page. It turns out that EF does not go well with triggers, because it fails to get the inserted ID. For me, the solution was to change the trigger so that the last executed code ......

Response.Clear();Response.C... = "application/pdf";Response.... "attachment;filename=\"File... SourceEnjoy :) ......

Hello, If you are reading this you probably have already realized that it is not possible to hide a column that was auto-generated using myGridView.Columns[index].V... To achieve this you must: 1 - set the OnRowCreated to execute a function, something like OnRowCreated="gridRowCreated" 2 - Create your function as such: protected void gridRowCreated(object sender, GridViewRowEventArgs e) { e.Row.Cells[yourIndexHere].... = false; } Hope this helps ;) ......

A few days ago I got an error report to fix. Some web application that I now maintain was inserting duplicate records. After a quick look it became obvious that the users where double clicking the submit button and that made the page post twice and so a duplicate record would appear. A quick fix dor this problem using javascript: <script language="javascript" type="text/javascript"> var haveSubmitted=false; function FirstSubmitOnly() { if (haveSubmitted) return false; haveSubmitted = true; ......

I think at some point everybody had this problem... A big form with some control that forces a postback. If you have scrolled down, the page scroll will be placed at the top.

To force the aspx to keep the scroll, just place the following instrucion on the <pages> tag of your web config.

<pages maintainScrollPositionOnPostBack="true">

Enjoy :)

Simple how to refresh page every 60 seconds <meta http-equiv="refresh" content="60"> ......

In global.asax: protected void Application_BeginRequest(Ob... sender, EventArgs e) { HttpRuntimeSection runTime = (HttpRuntimeSection)WebConf... //Approx 100 Kb(for page content) size has been deducted because the maxRequestLength proprty is the page size, not only the file upload size int maxRequestLength = (runTime.MaxRequestLength - 100) * 1024; //This code is used to check the request length of the page and if the request length is greater than ......

<script type="text/javascript" language="javascript">

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(refresh);

        function refresh() { //Your code here; }

</script>

 

Source


Type myType = typeof(MyClass);

string methodName = "methodNameAsString";

MethodInfo myTypeGetMethod = myType.GetMethod(methodName);

MyClass obj = new MyClass();

object[] parms = { 123, "string test"};

myTypeGetMethod.Invoke(obj, args);
 

 


        protected override void OnPreInit(EventArgs e)
        {
            Page.MasterPageFile = "~/LinkToMasterPage";
            base.OnInit(e);
        }

 

Enjoy :)


Full Asp.Net Archive