Friday, May 18, 2012

Read hidden field value in from jquery

Often we are confused about how to read values set in HiddenField from jquery and use the values in the web form. Many-a-times we see the threads over the forums about the difficulties associated with reading HiddenField values. I have tried to give easy and fast way to read values and set values of hidden filed in using jquery.
You may first download the latest jquery file from webform - design page
    <form id=\"form1\" runat=\"server\">
    <asp:HiddenField ID=\"HiddenField1\" runat=\"server\" />
    <asp:Label ID=\"lblSiteName\" runat=\"server\"></asp:Label>
    <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 Label control
            $(\'#lblSiteName\').html(\'My site is: \' + mySite);
            //setting value of HiddenField control
            $(\'#HiddenField1\').val(\'New site is:\')
</body> webform - code page (in c#)
protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            HiddenField1.Value = "";
Known issue
If you have put the 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 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 web application

Just a simple accidental error in 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 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:
  <add name="ConnectionString" connectionString="data source=my-pc;Integrated Security=true;Initial Catalog=mydbname"
   providerName="System.Data.SqlClient" />
And accidentally it was broken like:
  <add name="ConnectionString" connectionString="data source=my-pc;Integrated Security=true;Initial Catalog=mydbname" />
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 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 tips in this blog. To sate the appetite of enthusiasts, I have also posted a bunch of javascript with related tips and tricks which you may find useful in your web development career. Cheers! kick it on

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 :
But did not work with:
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.
kick it on

Thursday, March 22, 2012

The database principal owns a schema in the database, and cannot be dropped

While restoring a database backup file in my hosting I was prompted with some error message regarding existing user in the database. So I decided to delete those users. But while trying to delete the users from my local sql sever management studio, error occurred.
The database principal owns a schema in the database, and cannot be dropped.
I tried out browsing the property of the user and removing the assigned scheme from the lists. It was somehow unsucessful. So I decided to go search for the solution and stumbled at doing it the most powerful way - through command.
Here goes the solution - Revoke the database schema assigned to the user and assign it back to the default db object.
ALTER AUTHORIZATION ON SCHEMA :: my_user_name to db_owner
 If you want to assign the schema  to another user, here is how you accomplish it.
 ALTER AUTHORIZATION ON SCHEMA :: my_schema_name to my_user_name
kick it on

Monday, March 5, 2012

Invitation to connect on LinkedIn

sangam uprety
From sangam uprety
Executive Director at Time Infotech

I'd like to add you to my professional network on LinkedIn.

- sangam

You are receiving Invitation to Connect emails. Unsubscribe
© 2012, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA

Tuesday, February 7, 2012

Installing sql server 2005 express in windows 7

If you started with sql server 2005 express editions in your windows vista or xp operating systems, you are sure to stumble while installing sql server 2005 express in windows 7. After having long time experience of sql server 2005 express in my windows vista, I just switched to windows 7 and tried same version of express in it. But it is not supported. You get the failure message sort of:
This software is not supported in this version of operating system.
The simple solution is to acquire SQL Server 2005 Express Service Pack 3. Choose 32 bit or 64 bit version according to your machine.

The story does not finish yet. If you are looking for sql server management studio express, you again have to look for service pack 3 of sql server 2005 management studio. Get SQL Server 2005 Management Studio Express Service Pack 3 and get installed in your machine. Still don't forget to choose right version matching to your machine (32 or 64 bit).

Happy upcoming Valentine's Day!

Popular Posts

Recent Articles