Saturday, January 19, 2013

Learning Java - I am using Eclipse IDE

For a long time, I have remained asp.net web application developer. But as you prepare to bear the role of an academician also, how could you stick to only one programming framework or programming language? Yes, that has come to my life also. And I have growing appetite for learning more programming languages.

JAVA undoubtedly brought about revolutions in so many fields. Oracle proudly declares that millions of devices run with JAVA. The academic world loves C, C++ and JAVA equally for the ongoing researches in so may fields of science and engineering.

To get my hands dirty with the first few programs in JAVA, I downloaded eclipse - the most popular Integrated Development Environment (IDE) for JAVA. I hope to come up with some samples soon.

For now, to elaborate "why java?", an excerpt from java site:

Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices. 

Happy programming!

Friday, May 18, 2012

Read hidden field value in asp.net from jquery

Often we are confused about how to read values set in asp.net HiddenField from jquery and use the values in the web form. Many-a-times we see the threads over the asp.net forums about the difficulties associated with reading asp.net HiddenField values. I have tried to give easy and fast way to read values and set values of hidden filed in asp.net using jquery.
You may first download the latest jquery file from jquery.com.
asp.net webform - design page
<body>
    <form id=\"form1\" runat=\"server\">
    <div>
    <asp:HiddenField ID=\"HiddenField1\" runat=\"server\" />
    <asp:Label ID=\"lblSiteName\" runat=\"server\"></asp:Label>
    </div>
    </form>
    <script type=\"text/javascript\" src=\"js/jquery-1.3.2.min.js\"></script>
    <script type=\"text/javascript\">
        $(function () {
            //reading hidden field value
            var mySite = $(\'#HiddenField1\').val();
            //displaying the value in an asp.net Label control
            $(\'#lblSiteName\').html(\'My site is: \' + mySite);
            //setting value of HiddenField control
            $(\'#HiddenField1\').val(\'New site is: http://asp.net\')
        });
    </script>
</body>
asp.net webform - code page (in c#)
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HiddenField1.Value = "http://dotnetspidor.blogspot.com";
        }
    }
Known issue
If you have put the asp.net HiddenField control below the script tags, you may end up reading 'undefined' values. To solve the issue, I recommend putting the hidden fields at the top of the page just below the form tag.
Further, if you are using asp.net Master Page, please make changes in the jquery codes respectively. In such case, I  recommend the following syntax:
var mySite=$('[id$=HiddenField1]').val();
The system $= means the value that end with HiddenField1. This works since you usually see the id HiddenFiled1 used with master page rendered as ctl00_ContentPlaceholder1_HiddenField1.

Happy programming!!
Shout it

Friday, April 27, 2012

Expecting non-empty string for 'providerInvariantName' parameter - database connection error in asp.net web application

Just a simple accidental error in asp.net web application's web.config file, and you see the following error:

Expecting non-empty string for 'providerInvariantName' parameter. 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.ArgumentException: Expecting non-empty string for 'providerInvariantName' parameter.
Fig. 1 Error page showing providerInvariantName parameter error for asp.net web application's database connection error
 The error occurred only because I had missed the providerName property in my connection string.
My connection string is:
<connectionStrings>
  <add name="ConnectionString" connectionString="data source=my-pc;Integrated Security=true;Initial Catalog=mydbname"
   providerName="System.Data.SqlClient" />
  </connectionStrings>
And accidentally it was broken like:
<connectionStrings>
  <add name="ConnectionString" connectionString="data source=my-pc;Integrated Security=true;Initial Catalog=mydbname" />
  </connectionStrings>
I was stunned to get the error when I had just finished uploading the web application to my host. After some googling, I found the cause and fixed the error. It worked. Happy programming!

Friday, April 20, 2012

Flexible jquery based modal box or popup box -ColorBox

I have been using the jquery plugins for long. Many times I do need to implement facebook-like photo viewer in gallery pages. Similarly, mostly in admin pages of my asp.net web applications, I frequently us modal pop-ups for various purposes like ajax loading of content, iframe loading from other internal pages, confirmation and error show ups. Typically I used to go for separate plugins for the purpose. Lately I found the ColorBox plugin that satisfies both the needs. In one sense, this is a framework for me. You can visit  ColorBox and explore it.

Lets look at the features the ColorBox jquery plugin possesses.
  • Supports photos, grouping, slideshow, ajax, inline, and iframed content.
  • Lightweight: 10KB of JavaScript (less than 5KBs gzipped).
  • Appearance is controlled through CSS so it can be restyled.
  • Can be extended with callbacks & event-hooks without altering the source files.
  • Completely unobtrusive, options are set in the JS and require no changes to existing HTML.
  • Preloads upcoming images in a photo group.
  • Well vetted. ColorBox is one of the top jQuery plugins.
For jquery 1.3.2+, ColorBox has its older version, whereas for jquery 1.4.3+, ColorBox has its news version.
Meantime, you may also enjoy browsing jquery with asp.net tips in this blog. To sate the appetite of enthusiasts, I have also posted a bunch of javascript with asp.net related tips and tricks which you may find useful in your asp.net web development career. Cheers! kick it on DotNetKicks.com

Thursday, April 12, 2012

Domain without www not working from plesk hosting

I use plesk hosting for my company. An error I got (and shocked with it!) was that my domain was displaying the correct site with :
http://mysitedomain.com
But did not work with:
http://www.mysitedomain.com
Later it was traced that, by default the www was not included while creating the domain.
So if you are creating a domain, don't forget to inlcude www (by checking a checkbox next to www). That will keep yourself away from the worry.
If you have already created the domain and have the problem, you can always go and edit the domain (from the very first page that lists all the domains) and update it to include www.
Cheers!
kick it on DotNetKicks.com

Popular Posts

Recent Articles