.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to omit null properties in object serialization

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net


I have a problem in object serialization , that i want to omit the null property in object to xml serialization . i.e.

My class is as
public class MainRoot

property string Element1

property List<element2> element2


public class element2
property sub1
property sub2

I want to not show the <sub2/> whereas it looks like;

View Complete Post

More Related Resource Links

'element.className' is null or not an object



I just downloaded the project, compiled it and ran it right out of the box and when I put the mouse pointer over or remove the mouse pointer from either MenuItem in the menu demo, I generate this error:

'element.className' is null or not an object

It points to this javascript method:

updateClassName: function(operation, element, name, value) {
        this[operation + 'String'](
                function() {
                    return element.className;
                function(newValue) {
                    element.className = newValue;

Microsoft JScript runtime error: 'Parent' is null or not an object


Hi friends,

        I got This Error : Microsoft JScript runtime error: 'Parent' is null or not an object

 In runtime,after  click on the check box, It Show "Microsoft JScript runtime error: 'Parent' is null or not an object"

<script language ="javascript" type ="text/javascript" >
        function SelectAllCheckboxesSpecific(spanChk)
           var IsChecked = spanChk.checked;
           var items=0;
           var Chk = spanChk;
              Parent = document.getElementById('gvUsers');          
              var items = Parent.getElementsByTagName('input');                         
              for(var i=0;i<items.length;i++)
                  if(items[i].id != Chk && items[i].type=="checkbox")
                      if(items[i].checked!= IsChecked)

please verify it. 

what is role of object properties when using client side validations ?


I have been using properties and have idea that using properties with private fields we can implement validations and buisness rules in them.

But I am just thinking asp.net client side validation controls provide good strength and they provide good user experience as well. They can be used for any type of validation (using regular expression) on client side and their re-use is possible on server side. When validation controls are a must and they are powerful; is making properties not just wastage of time ?

Is there still some use of properties ? Please guide me.


Properties of a child activity are null when the activity executes

I have an activity library containing several activites; one of my activities, let's call it MainActivity, contains another one, InnerActivity. A code block in MainActivity sets some properties of InnerActivity, but then when InnerActivity is executed, these properties are null. Some of these properties being set are dependency properties, other are "plain" properties. I had done the same thing in another activity and had got no problems at all. Any hints why this is happening? Thanks, PaoloPaolo Tedesco - http://cern.ch/idm

Null Reference Exception was not handled by user Object Reference not set to instance of an object

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Security.Principal;using System.Data;using System.Data.SqlClient;using System.Windows;using System.Collections; public partial class Default2 : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {     }    private bool tableCopied = false;    private DataTable originalDataTable;     protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)    {         if (e.Row.RowType == DataControlRowType.DataRow)        {            //string sValue = e.Row.Cells[3].Text;             if (!tableCopied)            {                originalDataTable = ((System.Data.DataRowView)e.Row.DataItem).Row.Table.Copy();                ViewState["originalDataTable"] = originalDataTable;      &nbs

Javascript "Undefined is null or not an object" error in IE :S

I read around and tried everything to figure out the reason of the issue i'm getting, but i give up, the error i'm getting is only on IE and it's the "Undefined is null or not an object" error.This is it:Line: 29Char: 13Error: 'undefined' is null or not an objectCode: 0This is the script:<script type="text/javascript">    function checkV1() {        if (document.getElementById('CB1').checked)            ValidatorEnable(document.getElementById('CheckBoxListValidator1'), true);        else            ValidatorEnable(document.getElementById('CheckBoxListValidator1'), false);    }    function checkV2() {        if (document.getElementById('CB2').checked)            ValidatorEnable(document.getElementById('CheckBoxListValidator2'), true);        else            ValidatorEnable(document.getElementById('CheckBoxListValidator2'), false);    }THIS IS LINE 29---->    fun

How to control the text and other properties in ResourceDictionary object that i wrote ?

I wrote some ResourceDictionary. This ResourceDictionary is actuly a button that i use - I created this button by using Rectangle and TextBlock ==> that mean that the my xaml look like the code below. The problem is that i cant change the font size and the text of the TextBlock. I can change is just from the xaml of the template. And ... How can i define some variable that will control on the rectAngle redius in runtime ? Someone can help ?? ? Thanks. ...<ResourceDictionary> <Style x:Key="MyBtn" TargetType="{x:Type Button}"> <Rectangle ... <TextBlock.... </ResourceDictionary> ...

Null Request object in Controller

I have a need to display user-specific information in my master page.  As a result, I have set up all of my controllers to be inherited from a "master" controller.  This has worked well for other aspects of the master page, such as displaying random quotes.  However, while using this technique to incorporate the user-specific information, I ran into a problem where, when I check the Request.IsAuthenticated value, the Request object is null. Here is my "master" controller:namespace MetalMine.Controllers { using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MyApp.Models; public abstract class ApplicationController : Controller { private DataContext dataContext = new DataContext(); { ViewData["Quote"] = this.dataContext.GetRandomQuote(); // this is where the Request object is null if (this.Request.IsAuthenticated) { // the User object, here, is also null, BTW ViewData["User"] = this.dataContext.GetUser(this.User.Identity.Name); } } } } Curiously - at least to me - is that the Request object becomes populated by the time program flow hits the Home Controller:namespace MetalMine.Controllers { [HandleError] publ

'null' is null or not an object - DragPanelExtender

Ok, I've been banging my head for hours with this... I have a bunch of ajax controls on my aspx page: a dragpanel and a few accordions. The dragpanel has dynamic content (an image) and appears (visible = true) upon clicking on the link buttons listed in the accordions (no update panel used). On page postback, when one of the buttons is clicked, the drag panel pops up and is positioned over another larger image. Here's what the code looks like:<asp:Panel ID="MyHandle" runat="server" Visible="false"> </asp:Panel> <asp:Panel ID="odragpanel" runat="server" Visible="false"> <asp:Image ID="myoimage" runat="server" ImageUrl="" /> </asp:Panel> <ajaxToolkit:DragPanelExtender ID="DragPanelExtender1" runat="server" DragHandleID="MyHandle" Enabled="false" TargetControlID="odragpanel" BehaviorID="myodragpanel"> </ajaxToolkit:DragPanelExtender> When a user selects a link button from the accordion, the visible properties are set to "true" and the drag panel extender is enabled. This is the next block of code that runs on client side:<script type="text/javascript"> jQuery.noConflict(); window.onload = function() { positionm

'this.get_element().style' is null or not an object

I've been getting this error message fairly often. A page will work normaly for a while, but eventualy I get the error: 'this.get_element().style' is null or not an object  Once I get the error it seems to happen most of the time. It seems like it might be from the update progress control.   Any ideas? -A    

Persistant Status Bar Notification ... error 'SP.UI.Status' is null or not an object

I want to show a status bar that needs to be persistent on a page. for this I used the following in my master page function ShowStatusBarMessage(title, message) { var statusId = SP.UI.Status.addStatus(title, message, true); SP.UI.Status.setStatusPriColor(statusId, 'yellow'); /* Set a status-color */ } HTML, call the JS method: <a onclick="ShowStatusBarMessage('Title'!','Awesome message!')"> Display Status Bar message! </a> ref: http://www.zimmergren.net/archive/2010/03/17/sp-2010-dynamically-displaying-messages-to-your-users-with-the-notification-and-status-bar-areas-in-sharepoint-2010.aspx   But what I want is to call the function on load. So I used pushed ny function to _spBodyOnLoadWrapper using _spBodyOnLoadFunctionNames.push("YourFunctionName");, it throws an error 'SP.UI.Status' is null or not an object Next I created and deployed a webcontrol and did a registerclientscript, that too gives me 'SP.UI.Status' is null or not an object // Define the name and type of the client scripts on the page. String csname1 = "AlertScript"; Type cstype = this.GetType(); // Get a ClientScriptManager reference from the Page class. ClientScriptManager cs = Page.ClientScript; // Check to see if the startup script is already registered. if (!cs.IsStartupScriptRegistered(cstype, csname1)) {

Controlling object serialization

I have a class called Marker and I've written SerializeToXml function that serializes the class to xml. The problem is that I'm getting xml declaration and namespace that I don't need. How can I set up the serialization so that this information is not included ? Code Snippet <?xml version="1.0" encoding="utf-16"?><Marker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">Here is my SerializeToXml function: Code Snippet public void SerializeToXML(System.IO.StringWriter writer){            XmlSerializer mySerializer = new XmlSerializer(typeof(Marker));                     mySerializer.Serialize(writer, this);} Thanks !

Details View Biding Custom Object with Enum properties fields

Hello, I'm trying to bind custom object to details view. The problem is that enum property fields are not show.Is there any way to show enum property fields in details view ?I put some example code below (I do not specify any rows mappings, they are generated dynamically because different kind of objects are bound to details view):// My object public class OrderItem { public ItemKindEnum unitemizedItemKind { get { return (ItemKindEnum)this.unitemizedItemKindID; } } ... } // Details view configuration <asp:DetailsView ID="dvOperationDetails" runat="server" DefaultMode="ReadOnly" ... />

Javasript error 'this.get_element() is null or not an object'

While testing an AJAX enabled web app I sometimes stumbled upon this script error: 'this.get_element().style' is null or not an object. It was a hard nut to crack this one.This was the actual message 'this.get_element() is null or not an object' The situation: AJAX Enabled web app using slider extenders . In some circumstances a script error is generated. In most cases it is not. The reason:It turned out that the error happens at times when a new Postback is triggered while a previous one hasnt finished yet. That is quickly changing the sliderhandle's position in this scenario. The Postback where triggered because i had set the AutoPostBack property of the extended TextBox to "true".I have some code running inside the event handler . Can anyone suggest an efficient solution for this problem ........................................................?  

Tab Panel inside a User control - null referance to text box with set properties

Hi guys, Im having problems with the following: I have a user control which has a tabbed panel inside, I then have a public property which populates a textbox inside the tabbed panel, HOWEVER when I access the property on my ASPX page, it give me a null referance to textbox, I have tried using findControl but still finds nothing, Please help!! ASPX PAGE  <Registration:UserDetails UserID="23" ID="RegistrationUserDetails" runat="server" /> USER CONTROL<cc1:TabContainer ID="TabContainerRegistration" runat="server" ActiveTabIndex="1" > <cc1:TabPanel runat="server" ID="TabPanelAccessDetails" HeaderText="Access details"> <ContentTemplate> <table> <tr> <td>User ID</td> </tr> <tr> <td><asp:TextBox ID="UserIDTextBox" ReadOnly="true" runat="server" SkinID="InputBoxes"></asp:TextBox></td> </tr> </table> </ContentTemplate> </cc1:TabPanel> </cc1:TabContainer> CODE BEHINDprivate int _UserID; public int UserID { set { TextBox tb = (TextBox)TabContainerRegistration.

'document.getElementById(...)' is null or not an object


i am making use of the following javascript at page_load event, to fill the default value of textbox, txtBuinessUserMailID at run time:

 void Page_Load(object sender, EventArgs e)//Initialize a stringbuilder object, much faster than string concatenation


Message: '_onSubmitStatements' is null or not an object



I am getting this error:

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Wed, 22 Sep 2010 16:29:25 UTC

Message: '_onSubmitStatements' is null or not an object
Line: 139
Char: 1
Code: 0
URI: http://localhost/ScriptResource.axd?d=tZ3JCSii4EBM-tx4hEokGcwHyUFbgrEZpCEYoSnucLTc6JYWo2bAUxru-077QmJamzQWn-57TS-gCWMEOCyeIodqSlLvi4Ux0&t=634057278000000000

in my application for a module that displays detailed data in a tab control. I think I have determined the TabContainer1 is the name of the "This" element that is having the issue. I figured this out by debugging the ScriptResource.axd file. Here is the offending lines of code:

Line# 138 = if (typeof(Sys.WebForms)!=="undefined" && typeof(Sys.WebForms.PageRequestManager)!=="undefined") {
Line# 139 = Array.add(Sys.WebForms.PageRequestManager.getInstance()._onSubmitStatements, this._onsubmit$delegate);} else {
Line# 140 = $addHandler(document.forms[0], "submit", this._onsubmit$delegate);}
Line# 141 = }

The way the app works is there are two modules that work together on the page. One is

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend