Causes And Fixes For "Error: Sys.ArgumentNullException: Value cannot be null." In JQuery



TODO:

You make some changes the ASP.net controls on your form, and possible your JQuery.  You run your application and you end up with "Error: Sys.ArgumentNullException: Value cannot be null."  

 

SOLUTION:

95% of the time I have had this issue, the problem was that I removed a control, and its references in the .cs file, but forgot it in the JQuery.  So in the JQuery I was doing a .hide() on the removed control which causes the cryptic error above.  To debug I simply looked for each instance of $('#mycontrolxxxxxxx').hide(); and made sure that #mycontrolxxxxxxx actually still existed.  Sure enough, I forgot to remove a JQuery line.  Once I removed the rogue JQuery line, the issue went away. 

 

NOTES:

There are no notes on this topic.

Page_Load Is Called Twice



 TODO:

You have an Application Page, or regular ASPX page, .Net 3.5 and you notice that each Postback is happening twice, for no apparent reason.

 

SOLUTION:

If you have an IMG SRC="" tag, or a placeholder like IMG SRC="#" this will cause the issue.  If dynamically generating SRC values, be sure that it is actually being populated with a valid image path.

 

NOTES:

This bug has been fixed in .Net 4.0+

How To Fix The Problem Of Telerik RadAjaxLoadingPanel Only Loading On First Postback



TODO:

I recently had an issue, where the RadAjaxLoadingPanel would only load on the first button click.  This was frustrating, and like many things Telerik, there are 10 answers and 0.5 of them work.  To fix this, I hooked into the button click event in JQuery, and then showed the loading panel manually from there.


SOLUTION:

<telerik:RadCodeBlock ID="rcbInitHandler"runat="server">
     <script type="text/javascript">
            //global variables
            var currentLoadingPanel = null;
            var currentUpdatedControl = null;
            
            
            //add the init activity
            Sys.Application.add_init(appl_init);

            //Do this on init
            function appl_init() {
                var pgRegMgr = Sys.WebForms.PageRequestManager.getInstance();
                pgRegMgr.add_endRequest(EndHandler);
                pgRegMgr.add_beginRequest(BeginHandler);
            }

            //Called before async postback
            function BeginHandler() {
                document.body.style.cursor = 'wait';
            }

            //Called after async postback
            function EndHandler() {
                if (currentLoadingPanel != null && currentUpdatedControl != null)
                    currentLoadingPanel.hide(currentUpdatedControl);
                currentUpdatedControl = null;
                currentLoadingPanel = null;
                document.body.style.cursor ='default';
            }

            //Show the loading panel
            function ShowLoadingPanel() {
                currentLoadingPanel = $find('<%=rdlpLoadingPanel.ClientID%>');
                currentUpdatedControl ='<%=pnlSomePanel.ClientID%>';
                currentLoadingPanel.show(currentUpdatedControl);
            }

            $(document).ready(function () {
                 //Register buttons so we get pop-up.  we could have done all buttons, but we do not want to get the grid button
                 $('#<%=btnLoad.ClientID%>').live("click",function () {
                     ShowLoadingPanel();
                 });
            });
     </script>
</telerik:RadCodeBlock>


NOTES:

You will need a Loading Panel called rdlLoadingPanel, a panel called pnlSomePanel, and a button called btnLoad.  The rest is pretty self explanatory.

 

 

 

 

 

How To Get The Selected Value Of a RadioButtonList In JQuery



TODO:

Have you ever wanted to get the selected value of a RadioButtonList using JQuery?  You can do it via CssClass, but in this example, I want to target a particular control.

 

SOLUTION:

//handle nothing being checked
if ($("#<%= rblMyRadioList.ClientID %> input:checked").val() == null) {
     return;
}

var selectedValue = $("#<%= rblMyRadioList.ClientID %> input:checked").val().toUpperCase();

 

NOTES:

There are no notes on this topic.

How To Add OnBlur Or OnFocus To A TextBox In The Codebehind



TODO:

Have you ever wanted to add the onblur or onfocus event to a TextBox in the Codebehind?


SOLUTION:

//add focus
myTextbox.Attributes.Add("onfocus", "MyJavascriptFocusFunction(this);");

//add blur
myTextbox.Attributes.Add("onblur", "MyJavascriptBlurFunction(this);");

 

NOTES:

There are no notes on this topic.

How To Call Click Event On A Button When Retern Is Pressed On A TextField In The Codebehind



TODO:

Have you ever wanted to "click" a button when someone presses return on a Textbox?  The code below, goes in the codebehind of your aspx file.

 

SOLUTION:

myTextBox.Attributes.Add("onkeypress", "if(event.keyCode==13) {document.getElementById('" + myButton.ClientID + "').click(); return false;}");

 

NOTES:

There are no notes on this topic.

How To Execute Javascript Before Async Postback



TODO:

Have you ever wanted to execute some javascript before an async postback?  Place the below code in your aspx file, just under the Main Content Placeholder, or body tag if you are not using a master page.

 

SOLUTION:

     <script type="text/javascript">
          
          //add the init activity
          Sys.Application.add_init(appl_init);

          //Do this on init
          function appl_init() {
               var pagegReqManager = Sys.WebForms.PageRequestManager.getInstance();
               pagegReqManager.add_beginRequest(BeginHandler);
          }

          //Called before async postback
          function BeginHandler() {
               MyJavascriptMethod();
               MyOtherJavascriptMethod();
          }      
     </script>

 

NOTES:

There are no notes on this topic

How To Fix 'Recycle IIS Application Pool: Provider load failure' With Visual Studio And Sharepoint



TODO:

Have you ever received the dreaded 'Recycle IIS Application Pool:  Provider load failure' message when trying to deploy and run a Sharepoint Solution from Visual Studio?  No need to reboot, just put the following lines in a .bat file, and run it as Administrator.

 

SOLUTION:

net stop SPTimerV4
net start SPTimerV4
net stop SPUserCodeV4
net start SPUserCodeV4
net stop SPAdminV4
net start SPAdminV4
REM net stop TrustedInstaller
REM net start TrustedInstaller
REM net stop Winmgmt
REM net start Winmgmt
REM net stop W3SVC
REM net start W3SVC
iisreset
 

NOTES:

If that does not work, try removing the REM statements, and it should work..

How to Fix: The web server process that was being debugged has been terminated by IIS. this can be avoided by configuring application pool setting in IIS. see help for further details.



TODO:

Have you been debugging an ASP .Net application and get the error:

"The web server process that was being debugged has been terminated by IIS. this can be avoided by configuring application pool setting in IIS. see help for further details."

 

 SOLUTION:

Go to the advanced settings in your application pool and set Ping Enabled to false.

App Pool -> Advanced ->  Ping Enabled -> Set to false

 

NOTES:

There are no notes on this topic