tag:blogger.com,1999:blog-6306476302286612562024-03-13T17:29:04.779+05:30Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & moreCoding Cluster - using asp.net, c#, mvc 4, php, ios, sql, mysql, sqlite3 iphone, javascript, in asp.net mvc 3, jquery and more...Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.comBlogger153125tag:blogger.com,1999:blog-630647630228661256.post-39004314030900788542015-03-03T17:09:00.001+05:302015-03-03T17:11:33.888+05:30Download: ASP.NET mvc4: Get response from authorize.net after payment (Auto redirect)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
In this post we will learn how to get response from
Authorize.Net credit card payment using ASP.NET MVC4</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
One of my client projects I need to implement Authorize.net
payment gateway. So just implemented using SIM (Server Integration Method). But
my client wants, if the payment getting success then shown a custom receipt
page and save the transaction details in to our own database. In other case if the
payment getting fail then provides repayment option.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In SIM method this is not possible (or not advisable) because
we using “x_relay_response” to get response from Authorize.net. Note,this is just relay the url, not redirect to the result page. And URL always points to
the <span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"><a href="https://test.authorize.net/gateway/transact.dll">https://test.authorize.net/gateway/transact.dll</a></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">.</span>
And the response time also only 10 seconds. If your server not responds within
10 seconds then you get time out error like</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
“An error occurred while trying to report this transaction
to the merchant. An email has been sent to the merchant informing them of the
error. The following is a result of the attempt to charge your credit card.”</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
This error indicates that Authorize.Net is unable to connect
to the page that you have specified as your relay response URL. To avoid this
kind of errors you need to go with Authorize.net’s another one integration
method AIM (Advanced Integration Method)</div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
You can get more about AIM method from here <a href="http://www.authorize.net/support/AIM_guide.pdf">http://www.authorize.net/support/AIM_guide.pdf</a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>Implement AIM :</b></div>
<div class="MsoNormal">
First create a sandbox account in Authorize.Net. https://developer.authorize.net/sandbox/. After you registered you will get the API Credentials</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
API Login ID</div>
<div class="MsoNormal">
Transaction Key</div>
<div class="MsoNormal">
Secret Question<br />
<br />
Create you view page as per your requirement. Here I'm taking from Authorize.net default payment screen<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-GgWLwAqrCWE/VPWZOR5HkYI/AAAAAAAAAdk/lWb4-M-_a8E/s1600/ASP.Net%2BMVC-%2Bmake%2Bpayment%2Band%2Bget%2Bresponse%2Bfrom%2Bauthorize%2Bdot%2Bnet%2Busing%2BAIM%2Bmethod.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-GgWLwAqrCWE/VPWZOR5HkYI/AAAAAAAAAdk/lWb4-M-_a8E/s1600/ASP.Net%2BMVC-%2Bmake%2Bpayment%2Band%2Bget%2Bresponse%2Bfrom%2Bauthorize%2Bdot%2Bnet%2Busing%2BAIM%2Bmethod.png" height="180" width="320" /></a></div>
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Then add that details into your web.config file</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<!-- Sample code for get response from authorize.net --><br />
<div class="source-code">
<!-- Payment Authorize.NET - Begins -->
<<span style="color: blue;">add</span> key=<span style="color: #a31515;">"Payment.AuthLoginID"</span> <span style="color: blue;">value</span>=<span style="color: #a31515;">"XXXXXXXXXX"</span> />
<<span style="color: blue;">add</span> key=<span style="color: #a31515;">"Payment.AuthTransactionKey"</span> <span style="color: blue;">value</span>=<span style="color: #a31515;">"XXXXXXXXX"</span> />
<<span style="color: blue;">add</span> key=<span style="color: #a31515;">"Payment.TestMode"</span> <span style="color: blue;">value</span>=<span style="color: #a31515;">"true"</span> />
<<span style="color: blue;">add</span> key=<span style="color: #a31515;">"Payment.URL"</span> <span style="color: blue;">value</span>=<span style="color: #a31515;">"https://test.authorize.net/gateway/transact.dll"</span> />
<!--<<span style="color: blue;">add</span> key=<span style="color: #a31515;">"Payment.URL"</span> <span style="color: blue;">value</span>=<span style="color: #a31515;">"https://secure.authorize.net/gateway/transact.dll"</span> />-->
<!-- Payment Authorize.NET - End -->
</div>
</div>
<div>
<br />
<br />
Then call the following function into your post method<br />
<br />
<!-- Download sample project for authorize.net payment with respons --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">private</span> <span style="color: #2b91af;">string</span> AuthorizePayment(PaymentDataModel payDataModel)
{
<span style="color: #2b91af;">string</span> AuthNetVersion = <span style="color: #a31515;">"3.1"</span>; <span style="color: green;">// Contains CCV support</span>
<span style="color: #2b91af;">string</span> AuthNetLoginID = System.Configuration.ConfigurationManager.AppSettings[<span style="color: #a31515;">"Payment.AuthLoginID"</span>].ToString();
<span style="color: #2b91af;">string</span> AuthNetTransKey = System.Configuration.ConfigurationManager.AppSettings[<span style="color: #a31515;">"Payment.AuthTransactionKey"</span>].ToString();
<span style="color: #2b91af;">string</span> AuthNetMode = System.Configuration.ConfigurationManager.AppSettings[<span style="color: #a31515;">"Payment.TestMode"</span>].ToString();
WebClient objRequest = <span style="color: blue;">new</span> WebClient();
System.Collections.Specialized.NameValueCollection objInf = <span style="color: blue;">new</span> System.Collections.Specialized.NameValueCollection(30);
System.Collections.Specialized.NameValueCollection objRetInf = <span style="color: blue;">new</span> System.Collections.Specialized.NameValueCollection(30);
<span style="color: #2b91af;">byte</span>[] objRetBytes;
<span style="color: #2b91af;">string</span>[] objRetVals;
<span style="color: #2b91af;">string</span> retMessage;
objInf.Add(<span style="color: #a31515;">"x_version"</span>, AuthNetVersion);
objInf.Add(<span style="color: #a31515;">"x_delim_data"</span>, <span style="color: #a31515;">"True"</span>);
objInf.Add(<span style="color: #a31515;">"x_login"</span>, AuthNetLoginID);
<span style="color: green;">// objInf.Add("x_password", AuthNetPassword);</span>
objInf.Add(<span style="color: #a31515;">"x_tran_key"</span>, AuthNetTransKey);
objInf.Add(<span style="color: #a31515;">"x_relay_response"</span>, <span style="color: #a31515;">"False"</span>);
<span style="color: green;">// Switch this to False once you go live</span>
objInf.Add(<span style="color: #a31515;">"x_test_request"</span>, AuthNetMode);
objInf.Add(<span style="color: #a31515;">"x_delim_char"</span>, <span style="color: #a31515;">","</span>);
objInf.Add(<span style="color: #a31515;">"x_encap_char"</span>, <span style="color: #a31515;">"|"</span>);
<span style="color: green;">// Billing Address</span>
objInf.Add(<span style="color: #a31515;">"x_first_name"</span>, payDataModel.FirstName);
objInf.Add(<span style="color: #a31515;">"x_last_name"</span>, payDataModel.LastName);
objInf.Add(<span style="color: #a31515;">"x_address"</span>, payDataModel.Address);
objInf.Add(<span style="color: #a31515;">"x_city"</span>, payDataModel.City);
objInf.Add(<span style="color: #a31515;">"x_state"</span>, payDataModel.State);
objInf.Add(<span style="color: #a31515;">"x_zip"</span>, payDataModel.ZIP);
objInf.Add(<span style="color: #a31515;">"x_country"</span>, payDataModel.Country);
objInf.Add(<span style="color: #a31515;">"x_email"</span>, payDataModel.Email);
objInf.Add(<span style="color: #a31515;">"x_fax"</span>, payDataModel.Fax);
objInf.Add(<span style="color: #a31515;">"x_phone"</span>, payDataModel.Phone);
objInf.Add(<span style="color: #a31515;">"x_description"</span>, payDataModel.Description);
<span style="color: green;">// Card Details</span>
objInf.Add(<span style="color: #a31515;">"x_card_num"</span>, payDataModel.CardNumber);
objInf.Add(<span style="color: #a31515;">"x_exp_date"</span>, payDataModel.CardExpiryDate);
<span style="color: green;">// Authorisation code of the card (CCV)</span>
objInf.Add(<span style="color: #a31515;">"x_card_code"</span>, payDataModel.CCV);
objInf.Add(<span style="color: #a31515;">"x_method"</span>, <span style="color: #a31515;">"CC"</span>);
objInf.Add(<span style="color: #a31515;">"x_type"</span>, <span style="color: #a31515;">"AUTH_CAPTURE"</span>);
objInf.Add(<span style="color: #a31515;">"x_amount"</span>, payDataModel.Amount);
<span style="color: green;">// Currency setting. Check the guide for other supported currencies</span>
objInf.Add(<span style="color: #a31515;">"x_currency_code"</span>, <span style="color: #a31515;">"USD"</span>);
<span style="color: blue;">try</span>
{
<span style="color: green;">// Pure Test Server</span>
objRequest.BaseAddress = System.Configuration.ConfigurationManager.AppSettings[<span style="color: #a31515;">"Payment.URL"</span>].ToString().Trim();
objRetBytes = objRequest.UploadValues(objRequest.BaseAddress, <span style="color: #a31515;">"POST"</span>, objInf);
objRetVals = System.Text.Encoding.ASCII.GetString(objRetBytes).Split(<span style="color: #a31515;">","</span>.ToCharArray());
<span style="color: blue;">if</span> (objRetVals[0].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>)) == <span style="color: #a31515;">"1"</span>)
{
<span style="color: green;">// Returned Authorisation Code</span>
ViewBag.AuthNetCode = objRetVals[4].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>));
<span style="color: green;">// Returned Transaction ID</span>
ViewBag.AuthNetTransID = objRetVals[6].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>));
<span style="color: blue;">return</span> retMessage = <span style="color: #a31515;">"1"</span>;
}
<span style="color: blue;">else</span>
{
<span style="color: green;">// Error!</span>
retMessage = objRetVals[3].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>)) + <span style="color: #a31515;">" ("</span> + objRetVals[2].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>)) + <span style="color: #a31515;">")"</span>;
<span style="color: blue;">if</span> (objRetVals[2].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>)) == <span style="color: #a31515;">"44"</span>)
{
<span style="color: green;">// CCV transaction decline</span>
retMessage += <span style="color: #a31515;">"Our Card Code Verification (CCV) returned the following error: "</span>;
<span style="color: blue;">switch</span> (objRetVals[38].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>)))
{
<span style="color: blue;">case</span> <span style="color: #a31515;">"N"</span>:
retMessage += <span style="color: #a31515;">"Card Code does not match."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"P"</span>:
retMessage += <span style="color: #a31515;">"Card Code was not processed."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"S"</span>:
retMessage += <span style="color: #a31515;">"Card Code should be on card but was not indicated."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"U"</span>:
retMessage += <span style="color: #a31515;">"Issuer was not certified for Card Code."</span>;
<span style="color: blue;">break</span>;
}
}
<span style="color: blue;">if</span> (objRetVals[2].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>)) == <span style="color: #a31515;">"45"</span>)
{
<span style="color: blue;">if</span> (retMessage.Length > 1)
retMessage += <span style="color: #a31515;">"<br />n"</span>;
<span style="color: green;">// AVS transaction decline</span>
retMessage += <span style="color: #a31515;">"Our Address Verification System (AVS) returned the following error: "</span>;
<span style="color: blue;">switch</span> (objRetVals[5].Trim(<span style="color: #2b91af;">char</span>.Parse(<span style="color: #a31515;">"|"</span>)))
{
<span style="color: blue;">case</span> <span style="color: #a31515;">"A"</span>:
retMessage += <span style="color: #a31515;">" the zip code entered does not match the billing address."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"B"</span>:
retMessage += <span style="color: #a31515;">" no information was provided for the AVS check."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"E"</span>:
retMessage += <span style="color: #a31515;">" a general error occurred in the AVS system."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"G"</span>:
retMessage += <span style="color: #a31515;">" the credit card was issued by a non-US bank."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"N"</span>:
retMessage += <span style="color: #a31515;">" neither the entered street address nor zip code matches the billing address."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"P"</span>:
retMessage += <span style="color: #a31515;">" AVS is not applicable for this transaction."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"R"</span>:
retMessage += <span style="color: #a31515;">" please retry the transaction; the AVS system was unavailable or timed out."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"S"</span>:
retMessage += <span style="color: #a31515;">" the AVS service is not supported by your credit card issuer."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"U"</span>:
retMessage += <span style="color: #a31515;">" address information is unavailable for the credit card."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"W"</span>:
retMessage += <span style="color: #a31515;">" the 9 digit zip code matches, but the street address does not."</span>;
<span style="color: blue;">break</span>;
<span style="color: blue;">case</span> <span style="color: #a31515;">"Z"</span>:
retMessage += <span style="color: #a31515;">" the zip code matches, but the address does not."</span>;
<span style="color: blue;">break</span>;
}
}
<span style="color: green;">// strError contains the actual error</span>
ViewBag.ErrorMsg = retMessage;
<span style="color: blue;">return</span> retMessage;
}
}
<span style="color: blue;">catch</span> (Exception ex)
{
<span style="color: blue;">return</span> retMessage = ex.Message;
}
}
</pre>
</div>
</div>
That's it. You can <a href="https://app.box.com/s/h46ask0tvs1zjk6tjn02b0jda4aohdob" target="_blank">download sample for get response from authorize.net payment gateway using asp,net mvc project</a>. Please share this post to social media if its is help you and also don't forgot to write some comments. </div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com1tag:blogger.com,1999:blog-630647630228661256.post-86318061002440675772014-09-04T15:00:00.000+05:302014-09-04T15:03:40.867+05:30Solution:Error during serialization or deserialization using the json javascriptserializer. the length of the string exceeds<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="color: blue;">Error: </span></b><br />
"Error during serialization or deserialization using the json javascriptserializer. the length of the string exceeds kendoui" I faced this error in Kendo-Grid.<br />
<span style="color: blue;"><br /></span>
<b><span style="color: blue;">Reason:</span></b><br />
This exception is raised when the length of the data serialized as JSON exceeds the default MaxJsonLength. It means The JavaScript Serialization settings allow maximum 2097152 character by default. But getMethod return string larger then this then it throw above error.<br />
<br />
<b><span style="color: blue;">Solutions:</span></b><br />
According from the documents There are few possible solutions available to fix this issue<br />
<br />
<ul style="text-align: left;">
<li>Setting the MaxJsonLength property default value within your web.config</li>
</ul>
<ul style="text-align: left;">
<li>Return a custom action result</li>
</ul>
<ul style="text-align: left;">
<li>Setting the MaxJsonLength property of a JavascriptSerializer object to perform your serialization.</li>
</ul>
<ul style="text-align: left;">
<li>Enable paging by calling the Pageable method</li>
</ul>
<ul style="text-align: left;">
<li>Use a View Model to serialize only the required properties of your model</li>
</ul>
<br />
<span style="color: blue;"><b>Solution 1:</b></span> Setting the MaxJsonLength property default value within your web.config<br />
The MaxJsonLength property which can be set within the web.config of your application controls the maximum size of the JSON strings that are accepted by the JsonSerializer class. The default value is 2097152 characterswhich is equivalent to 4 MB of Unicode string data.<br />
<br />
This will only apply to web-services that handle JSON.<br />
<br />
You can just copy and paste the following code to your web.config file to increase the size of this value
<!-- Handling Larger JSON String Values in .NET and Avoiding Exceptions--><br />
<br />
<div class="source-code">
<span style="color: green; font-weight: bold;"><configuration></span><br />
<span style="color: green; font-weight: bold;"><system.web.extensions></span><br />
<span style="color: green; font-weight: bold;"> <scripting></span><br />
<span style="color: green; font-weight: bold;"> <webServices></span><br />
<span style="color: green; font-weight: bold;"> <jsonSerialization</span> <span style="color: #3d85c6;">maxJsonLength</span><span style="color: #7d9029;">=</span><span style="color: #ba2121;">"2097089"</span> <span style="color: green; font-weight: bold;">/></span><br />
<span style="color: green; font-weight: bold;"> </webServices></span><br />
<span style="color: green; font-weight: bold;"></scripting></span><br />
<span style="color: green; font-weight: bold;"></system.web.extensions></span><br />
<span style="color: green; font-weight: bold;"></configuration></span>
</div>
</div>
<br />
<b><span style="color: blue;">Solution 2: </span></b>Return a custom action result<br />
<!--JsonMaxLength exception on deserializing large json objects --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">public</span> ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
<span style="color: #2b91af;">var</span> data = GetData();
<span style="color: #2b91af;">var</span> serializer = <span style="color: blue;">new</span> JavaScriptSerializer();
<span style="color: #2b91af;">var</span> result = <span style="color: blue;">new</span> ContentResult();
serializer.MaxJsonLength = Int32.MaxValue; <span style="color: green;">// Whatever max length you want here</span>
result.Content = serializer.Serialize(data.ToDataSourceResult(request));
result.ContentType = <span style="color: #a31515;">"application/json"</span>;
<span style="color: blue;">return</span> result;
}
</pre>
<pre style="line-height: 125%; margin: 0;"></pre>
<pre style="line-height: 125%; margin: 0;"></pre>
</div>
<b><span style="color: blue;">Solution 3: </span></b>Setting the MaxJsonLength property of a JavascriptSerializer object<br />
<br />
Using an instance of a JavascriptSerializer will not actually inherit the previously defined within the web.config (as the web.config only applies to Web Services that handle the JSON) so you can easily just create an instance of the serializer and set the property accordingly :
<!-- maxJsonLength attribute in web.config is ignored --><br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: green;">//Creates an instance of your JavaScriptSerializer and Setting the MaxJsonLength</span>
<span style="color: #2b91af;">var</span> serializer = <span style="color: blue;">new</span> JavaScriptSerializer() { MaxJsonLength = 86753090 };
<span style="color: green;">//Perform your serialization</span>
serializer.Serialize(<span style="color: #a31515;">"Your JSON Contents"</span>);
</pre>
</div>
<br />
This will allow you to easily your larger data and adjust your maximum size easily.
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com2tag:blogger.com,1999:blog-630647630228661256.post-59265450609151059252014-08-26T10:34:00.001+05:302014-08-26T10:36:26.359+05:30Difference between jQuery .bind() vs .live() methods<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<b><span style="color: blue;">.bind():</span></b><br />
The .bind() method registers the type of event and an event handler directly to the DOM element in question. This method has been around the longest and in its day it was a nice abstraction around the various cross-browser issues that existed. This method is still very handy when wiring-up event handlers, but there are various performance concerns as are listed below.<br />
<br />
The .bind() method will attach the event handler to all of the anchors that are matched! That is not good. Not only is that expensive to implicitly iterate over all of those items to attach an event handler, but it is also wasteful since it is the same event handler over and over again.<br />
<br />
<b><span style="color: blue;">Pros</span></b><br />
This methods works across various browser implementations.<br />
It is pretty easy and quick to wire-up event handlers. The shorthand methods (.click(), .hover(), etc...) make it even easier to wire-up event handlers. For a simple ID selector, using .bind() not only wires-up quickly, but also when the event fires the event handler is invoked almost immediately.<br />
<br />
<span style="color: blue;"><b>Cons</b></span><br />
The method attaches the same event handler to every matched element in the selection.<br />
It doesn't work for elements added dynamically that matches the same selector.<br />
There are performance concerns when dealing with a large selection.<br />
The attachment is done upfront which can have performance issues on page load.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-hZk-dF9sPi0/U_wVHq6U0uI/AAAAAAAAAcY/OlWwgRVZl9U/s1600/difference%2Bbetween%2Bjquery%2Bbind()%2Band%2Blive().png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-hZk-dF9sPi0/U_wVHq6U0uI/AAAAAAAAAcY/OlWwgRVZl9U/s1600/difference%2Bbetween%2Bjquery%2Bbind()%2Band%2Blive().png" /></a></div>
<br />
<b><span style="color: blue;">.live():</span></b><br />
The .live method attaches the event handler to the root level document along with the associated selector and event information. By registering this information on the document it allows one event handler to be used for all events that have bubbled (a.k.a. delegated, propagated) up to it. Once an event has bubbled up to the document jQuery looks at the selector/event metadata to determine which handler it should invoke, if any. This extra work has some impact on performance at the point of user interaction, but the initial register process is fairly speedy.<br />
<br />
The good thing about this code as compared to the .bind() example above is that it is only attaching the event handler once to the document instead of multiple times. This not only is faster, but less wasteful,<br />
<br />
<b><span style="color: blue;">Pros</span></b><br />
There is only one event handler registered instead of the numerous event handlers that could have been registered with the .bind() method.The upgrade path from .bind() to .live() is very small. All you have to do is replace "bind" to "live". Elements dynamically added to the DOM that match the selector magically work because the real information was registered on the document. You can wire-up event handlers before the document ready event helping you utilize possibly unused time.<br />
<br />
<b><span style="color: blue;">Cons</span></b><br />
This method is deprecated as of jQuery 1.7 and you should start phasing out its use in your code.<br />
Chaining is not properly supported using this method.<br />
The selection that is made is basically thrown away since it is only used to register the event handler on the document.<br />
<br />
Using event.stopPropagation() is no longer helpful because the event has already delegated all the way up to the document.Since all selector/event information is attached to the document once an event does occur jQuery has match through its large metadata store using the matchesSelector method to determine which event handler to invoke, if any.<br />
Your events always delegate all the way up to the document. This can affect performance if your DOM is deep.</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com5tag:blogger.com,1999:blog-630647630228661256.post-31493666746461284062014-02-06T18:32:00.001+05:302014-08-26T10:36:12.543+05:30C#:Remove Special Characters from Text box in ASP.Net<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="color: blue;">Asp.net C# - Replace all special characters from string: </span></b><br />
"Input string was not in correct format" more or less all the .net programmers facing this issue at least one time in his carrier. Most of the times this issue caused by special characters mingle in data base query and it may entered via input controls. For example single quotes(') in address like "Peter's Road" in that time the SQL query binding with error due to that single quotes.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-nAtZjMfu7tg/UvOHNWV81-I/AAAAAAAAAaA/32UuBhe6jeQ/s1600/Remove+special+characters+from+text+box+using+c%23.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-nAtZjMfu7tg/UvOHNWV81-I/AAAAAAAAAaA/32UuBhe6jeQ/s1600/Remove+special+characters+from+text+box+using+c%23.png" height="233" width="320" /></a></div>
<!-- Restrict user from entering Special Characters in TextBox using c# --><br />
In this case we need to replace the special characters from the input values that produce this error. In c# the "String.Replace" method used to replace the string values. Here You can replace the user input's special characters by using the following c# method.<br />
<div>
<br /></div>
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">string</span> ReplaceSpecialCharacters(<span style="color: #2b91af;">string</span> strInput) {
strInput = strInput.Replace(<span style="color: #a31515;">"--"</span>, <span style="color: #a31515;">"++"</span>);
strInput = strInput.Replace(<span style="color: #a31515;">'&'</span>, <span style="color: #a31515;">','</span>);
strInput = strInput.Replace(<span style="color: #a31515;">"%"</span>, <span style="color: #a31515;">"[%]"</span>);
strInput = strInput.Replace(<span style="color: #a31515;">'+'</span>, <span style="color: #a31515;">','</span>);
strInput = strInput.Replace(<span style="color: #a31515;">"_"</span>, <span style="color: #a31515;">"[_]"</span>);
strInput = strInput.Replace(<span style="color: #a31515;">"["</span>, <span style="color: #a31515;">"[[]"</span>);
strInput = strInput.Replace(<span style="color: #a31515;">"]"</span>, <span style="color: #a31515;">"[]]"</span>);
strInput = strInput.Replace(<span style="color: #a31515;">"'"</span>, <span style="color: #a31515;">"''"</span>);
<span style="color: blue;">return</span> strInput;
}
</pre>
</div>
Just send your input control value as parameter:
<!-- Validation:How to remove special characters from textbox--><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: #2b91af;">string</span> txtAddress = StringHelper.ReplaceSpecialCharacters(txtAddress.Text.Trim());
</pre>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com1tag:blogger.com,1999:blog-630647630228661256.post-42155959540138591092014-02-04T14:32:00.001+05:302014-02-04T14:34:30.306+05:30 Get parameters value from .exe files using ASP.NET C#<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<b><a href="http://codingcluster.blogspot.in/2014/02/get-parameters-value-from-exe-files.html" target="_blank">ASP.net - Passing parameters to exe and receive from C#:</a></b></div>
<div class="MsoNormal">
In one of my project my clients requirements is scanning a
document from local scanner and directly upload into the server through web
application. But there is no direct method to access local machine from sever
code in dot net, so we need some other solutions to access local .exe (to
activate scanner) file from server.<br />
<br />
Finally Google answering me "ActiveX0bject".
Yes we can run .exe file from server by using ActiveX shell command. Here is
the sample code to run client's side .exe file from server by using JavaScript and ActiveX0bject.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Enable ActiveX controls in IE for run .exe files from local :</div>
<div class="MsoNormal">
Before we enable
ActiveX in IE settings with the following simple steps, </div>
<div class="MsoNormal">
<b><span style="color: blue;">Step -1:</span></b> Open IE -->Tools --> Internet Options</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: blue;">Step -2:</span></b> Go to
security tab choose your zone (Internet (OR) Local) then click custom Level button</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<b><span style="color: blue;">Step-3:</span></b> Just set
"<b>The Initialize and script ActiveX controls not marked as safe</b>" as
"<b>Prompt</b>"</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-8gfs8F2shA0/UuyiR0g6KzI/AAAAAAAAAZI/gc5b7ZuJwq0/s1600/Run+exe+file+from++client+side+javascript.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-8gfs8F2shA0/UuyiR0g6KzI/AAAAAAAAAZI/gc5b7ZuJwq0/s1600/Run+exe+file+from++client+side+javascript.png" height="320" width="246" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Bk4Go-DpAbs/UuyiR-GOdAI/AAAAAAAAAZU/T8TcQ34Dvus/s1600/Enable+activex+controls+in+ie+for+run+exe+files+from+local+.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-Bk4Go-DpAbs/UuyiR-GOdAI/AAAAAAAAAZU/T8TcQ34Dvus/s1600/Enable+activex+controls+in+ie+for+run+exe+files+from+local+.png" height="320" width="281" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
And the following JavaScript code is for run .exe (In my case
"ImageScanner.exe")file with parameter session id, display order and user id.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: blue;">JavaScript Code </span></b></div>
<!-- Run .exe file from server side using asp.net --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">function</span> runScaningApp(sessId, disorder, userId){
<span style="color: blue;">var</span> shell=<span style="color: blue;">new</span> ActiveX0bject(<span style="color: #a31515;">"WScript.shell"</span>);
<span style="color: blue;">var</span> res = shell.run(<span style="color: #a31515;">'"ImageScanner.exe" "'</span>+ sessId +<span style="color: #a31515;">'" "'</span>+ disorder+<span style="color: #a31515;">'" "'</span>+ userId+<span style="color: #a31515;">'", '</span>1<span style="border: 1px solid #FF0000;">'</span>, <span style="color: blue;">true</span>);
<span style="color: blue;">if</span> (res == <span style="color: #a31515;">"0"</span>){
alert (<span style="color: #a31515;">"Your success message"</span>);
}
<span style="color: blue;">else</span>{
alert (<span style="color: #a31515;">"Sorry! Some error occurred"</span>);
}
}
</pre>
</div>
<br />
Finally the following c# code for accessing the .exe's param value. Use this code in your .exe's .cs file <!-- Run client side .exe file from server side using asp.net --><br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">scanner</span> :system.Windows.Forms.Form, IMessageFilter{
<span style="color: blue;">private</span> <span style="color: #2b91af;">string</span> sessionId;
<span style="color: blue;">private</span> <span style="color: #2b91af;">string</span> disorder;
<span style="color: blue;">private</span> <span style="color: #2b91af;">string</span> userId;
<span style="color: blue;">public</span> Scanner (<span style="color: #2b91af;">string</span>[args){
sessionId = args [0];
disorder= args [1];
userId = args [2];
}
}
</pre>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-20873922791943307712014-02-04T14:23:00.001+05:302014-02-06T17:28:17.838+05:30Code for pure css menu<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<b>An attractive mouse hover menu using CSS only: </b> </div>
<div class="MsoNormal">
One of the fundamental things in web design in reference to
usability is navigation. Navigation menus are important to help the user find
the information that he or she seeks. Use of colors, highlights and mouse-over
effects will facilitate detection of the items that are being searched. </div>
<br />
<div class="MsoNormal">
In this post I give cool
css only menu. The items background change with rounded corner when mouse hover
. This menu build with css and 'UL' tag
only. Just copy and paste the following
html code to build this cool menu.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-crwqKQUrA_c/UvCV3LXgPqI/AAAAAAAAAZg/xzx1qBAuUDE/s1600/Pure+css+cool+menu.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-crwqKQUrA_c/UvCV3LXgPqI/AAAAAAAAAZg/xzx1qBAuUDE/s1600/Pure+css+cool+menu.gif" height="76" width="400" /></a></div>
<!-- Pure css cool menu --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">html</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">head</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">style</span><span style="color: #666666;">></span>
<span style="color: blue;">#topmenu</span> {
<span style="color: green; font-weight: bold;">float</span><span style="color: #666666;">:</span><span style="color: green; font-weight: bold;">left</span>;
<span style="color: green; font-weight: bold;">padding-right</span><span style="color: #666666;">:</span> <span style="color: #666666;">20px</span>;
<span style="color: green; font-weight: bold;">padding-left</span><span style="color: #666666;">:</span> <span style="color: #666666;">80px</span>;
<span style="color: green; font-weight: bold;">padding-top</span><span style="color: #666666;">:</span> <span style="color: #666666;">46px</span>;
<span style="color: green; font-weight: bold;">font-family</span><span style="color: #666666;">:</span> <span style="color: #ba2121;">'GibsonRegular'</span>;
}
<span style="color: blue;">#topmenu</span> <span style="color: green; font-weight: bold;">ul</span> {
<span style="color: green; font-weight: bold;">display</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">block</span>;
<span style="color: green; font-weight: bold;">height</span><span style="color: #666666;">:</span> <span style="color: #666666;">34px</span>;
<span style="color: green; font-weight: bold;">width</span><span style="color: #666666;">:</span> <span style="color: #666666;">540px</span>;
}
<span style="color: blue;">#topmenu</span> <span style="color: green; font-weight: bold;">ul</span> <span style="color: green; font-weight: bold;">li</span> {
<span style="color: green; font-weight: bold;">display</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">block</span>;
<span style="color: green; font-weight: bold;">float</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">left</span>;
<span style="color: green; font-weight: bold;">margin-right</span><span style="color: #666666;">:</span> <span style="color: #666666;">5px</span>;
}
<span style="color: blue;">#topmenu</span> <span style="color: green; font-weight: bold;">ul</span> <span style="color: green; font-weight: bold;">li</span> <span style="color: green; font-weight: bold;">a</span> {
<span style="color: #666666;">-</span>webkit<span style="color: #666666;">-</span><span style="color: green; font-weight: bold;">border</span><span style="color: #666666;">-</span>radius<span style="color: #666666;">:</span> <span style="color: #666666;">17px</span>;
<span style="color: #666666;">-</span>moz<span style="color: #666666;">-</span><span style="color: green; font-weight: bold;">border</span><span style="color: #666666;">-</span>radius<span style="color: #666666;">:</span> <span style="color: #666666;">17px</span>;
<span style="color: green; font-weight: bold;">border</span><span style="color: #666666;">-</span>radius<span style="color: #666666;">:</span> <span style="color: #666666;">17px</span>;
<span style="color: #666666;">-</span>webkit<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>property<span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">color</span><span style="color: #666666;">,</span> <span style="color: green; font-weight: bold;">border</span>;
<span style="color: #666666;">-</span>webkit<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>duration<span style="color: #666666;">:</span> <span style="color: #666666;">.2s</span>;
<span style="color: #666666;">-</span>webkit<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>timing<span style="color: #666666;">:</span> ease<span style="color: #666666;">-</span>in;
<span style="color: #666666;">-</span>moz<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>property<span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">color</span><span style="color: #666666;">,</span> <span style="color: green; font-weight: bold;">border</span>;
<span style="color: #666666;">-</span>moz<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>duration<span style="color: #666666;">:</span> <span style="color: #666666;">.2s</span>;
<span style="color: #666666;">-</span>moz<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>timing<span style="color: #666666;">:</span> ease<span style="color: #666666;">-</span>in;
<span style="color: #666666;">-</span>o<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>property<span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">color</span><span style="color: #666666;">,</span> <span style="color: green; font-weight: bold;">border</span>;
<span style="color: #666666;">-</span>o<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>duration<span style="color: #666666;">:</span> <span style="color: #666666;">.2s</span>;
<span style="color: #666666;">-</span>o<span style="color: #666666;">-</span>transition<span style="color: #666666;">-</span>timing<span style="color: #666666;">:</span> ease<span style="color: #666666;">-</span>in;
transition<span style="color: #666666;">-</span>property<span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">color</span><span style="color: #666666;">,</span> <span style="color: green; font-weight: bold;">border</span>;
transition<span style="color: #666666;">-</span>duration<span style="color: #666666;">:</span> <span style="color: #666666;">.2s</span>;
transition<span style="color: #666666;">-</span>timing<span style="color: #666666;">:</span> ease<span style="color: #666666;">-</span>in;
<span style="color: green; font-weight: bold;">display</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">block</span>;
<span style="color: green; font-weight: bold;">float</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">left</span>;
<span style="color: green; font-weight: bold;">font-size</span><span style="color: #666666;">:</span> <span style="color: #666666;">14px</span>;
<span style="color: green; font-weight: bold;">color</span><span style="color: #666666;">:</span> <span style="color: #666666;">#65778c</span>;
<span style="color: green; font-weight: bold;">text-decoration</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">none</span>;
<span style="color: green; font-weight: bold;">line-height</span><span style="color: #666666;">:</span> <span style="color: #666666;">30px</span>;
<span style="color: green; font-weight: bold;">height</span><span style="color: #666666;">:</span> <span style="color: #666666;">30px</span>;
<span style="color: green; font-weight: bold;">padding-left</span><span style="color: #666666;">:</span> <span style="color: #666666;">13px</span>;
<span style="color: green; font-weight: bold;">padding-right</span><span style="color: #666666;">:</span> <span style="color: #666666;">13px</span>;
<span style="color: green; font-weight: bold;">border</span><span style="color: #666666;">:</span> <span style="color: #666666;">2px</span> <span style="color: green; font-weight: bold;">solid</span> <span style="color: green; font-weight: bold;">transparent</span>;
}
<span style="color: blue;">#topmenu</span> <span style="color: green; font-weight: bold;">ul</span> <span style="color: green; font-weight: bold;">li</span> <span style="color: green; font-weight: bold;">a</span><span style="color: blue; font-weight: bold;">.active</span> {
<span style="color: green; font-weight: bold;">border</span><span style="color: #666666;">:</span> <span style="color: #666666;">2px</span> <span style="color: green; font-weight: bold;">solid</span> <span style="color: #666666;">#c8d8df</span>;
<span style="color: green; font-weight: bold;">color</span><span style="color: #666666;">:</span> <span style="color: #666666;">#DE3068</span>;
<span style="color: green; font-weight: bold;">text-decoration</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">none</span>;
}
<span style="color: blue;">#topmenu</span> <span style="color: green; font-weight: bold;">ul</span> <span style="color: green; font-weight: bold;">li</span> <span style="color: green; font-weight: bold;">a</span><span style="color: #aa22ff;">:hover</span> {
<span style="color: green; font-weight: bold;">border</span><span style="color: #666666;">:</span> <span style="color: #666666;">2px</span> <span style="color: green; font-weight: bold;">solid</span> <span style="color: #666666;">#c8d8df</span>;
<span style="color: green; font-weight: bold;">color</span><span style="color: #666666;">:</span> <span style="color: #666666;">#DE3068</span>;
<span style="color: green; font-weight: bold;">text-decoration</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">none</span>;
}
<span style="color: blue; font-weight: bold;">.ie7</span> <span style="color: blue;">#topmenu</span> <span style="color: green; font-weight: bold;">ul</span> <span style="color: green; font-weight: bold;">li</span> <span style="color: green; font-weight: bold;">a</span><span style="color: #666666;">,</span> <span style="color: blue; font-weight: bold;">.ie8</span> <span style="color: blue;">#topmenu</span> <span style="color: green; font-weight: bold;">ul</span> <span style="color: green; font-weight: bold;">li</span> <span style="color: green; font-weight: bold;">a</span> {
<span style="color: green; font-weight: bold;">line-height</span><span style="color: #666666;">:</span> <span style="color: #666666;">34px</span>;
<span style="color: green; font-weight: bold;">height</span><span style="color: #666666;">:</span> <span style="color: #666666;">34px</span>;
<span style="color: green; font-weight: bold;">padding-left</span><span style="color: #666666;">:</span> <span style="color: #666666;">15px</span>;
<span style="color: green; font-weight: bold;">padding-right</span><span style="color: #666666;">:</span> <span style="color: #666666;">15px</span>;
<span style="color: green; font-weight: bold;">border</span><span style="color: #666666;">:</span> <span style="color: green; font-weight: bold;">none</span>;
}
<span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">style</span><span style="color: #666666;">></span>
<span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">head</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">body</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">div</span> <span style="color: green; font-weight: bold;">id</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"topmenu"</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">ul</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">a</span> <span style="color: green; font-weight: bold;">href</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"#"</span> <span style="color: green; font-weight: bold;">title</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"Hello!"</span> <span style="color: green; font-weight: bold;">class</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"active"</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></span><span style="color: green; font-weight: bold;">Hello</span><span style="color: #666666;">!</</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">a</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">a</span> <span style="color: green; font-weight: bold;">href</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"#"</span> <span style="color: green; font-weight: bold;">title</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"Portfolio"</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></span><span style="color: green; font-weight: bold;">Portfolio</span><span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">a</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">a</span> <span style="color: green; font-weight: bold;">href</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"#"</span> <span style="color: green; font-weight: bold;">title</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"Services"</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></span><span style="color: green; font-weight: bold;">Services</span><span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">a</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">a</span> <span style="color: green; font-weight: bold;">href</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"#"</span> <span style="color: green; font-weight: bold;">title</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"About us"</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></span><span style="color: green; font-weight: bold;">About</span> <span style="color: green; font-weight: bold;">us</span><span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">a</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">></span>
<span style="color: #666666;"><</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">a</span> <span style="color: green; font-weight: bold;">href</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"#"</span> <span style="color: green; font-weight: bold;">title</span><span style="color: #666666;">=</span><span style="color: #ba2121;">"Blog"</span><span style="color: #666666;">><</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></span><span style="color: green; font-weight: bold;">Blog</span><span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">span</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">a</span><span style="color: #666666;">></</span><span style="color: green; font-weight: bold;">li</span><span style="color: #666666;">></span>
<span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">ul</span><span style="color: #666666;">></span>
<span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">div</span><span style="color: #666666;">></span>
<span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">body</span><span style="color: #666666;">></span>
<span style="color: #666666;"></</span><span style="color: green; font-weight: bold;">html</span><span style="color: #666666;">></span></pre>
</div>
<html>
<head>
<script type="text/javascript">
function showCoolMenuDemo(){
document.getElementById("topmenu").style.display = "inline";
return false;
}
</script>
<style>
#topmenu {
float:left;
padding-right: 20px;
padding-left: 80px;
padding-top: 46px;
font-family: 'GibsonRegular';
}
#topmenu ul {
display: block;
height: 34px;
width: 540px;
}
#topmenu ul li {
display: block;
float: left;
margin-right: 5px;
}
#topmenu ul li a {
-webkit-border-radius: 17px;
-moz-border-radius: 17px;
border-radius: 17px;
-webkit-transition-property: color, border;
-webkit-transition-duration: .2s;
-webkit-transition-timing: ease-in;
-moz-transition-property: color, border;
-moz-transition-duration: .2s;
-moz-transition-timing: ease-in;
-o-transition-property: color, border;
-o-transition-duration: .2s;
-o-transition-timing: ease-in;
transition-property: color, border;
transition-duration: .2s;
transition-timing: ease-in;
display: block;
float: left;
font-size: 14px;
color: #65778c;
text-decoration: none;
line-height: 30px;
height: 30px;
padding-left: 13px;
padding-right: 13px;
border: 2px solid transparent;
}
#topmenu ul li a.active {
border: 2px solid #c8d8df;
color: #DE3068;
text-decoration: none;
}
#topmenu ul li a:hover {
border: 2px solid #c8d8df;
color: #DE3068;
text-decoration: none;
}
.ie7 #topmenu ul li a, .ie8 #topmenu ul li a {
line-height: 34px;
height: 34px;
padding-left: 15px;
padding-right: 15px;
border: none;
}
</style>
</head>
<body>
<div>
<a class="css3button shape-2 blue effect-5" href="https://www.blogger.com/blogger.g?blogID=630647630228661256" onclick="showCoolMenuDemo()" style="cursor: pointer;">Demo</a>
</div>
<div id="topmenu" style="display: none;">
<ul>
<li><a class="active" href="https://www.blogger.com/blogger.g?blogID=630647630228661256#" title="Hello!"><span>Hello!</span></a></li>
<li><a href="https://www.blogger.com/blogger.g?blogID=630647630228661256#" title="Portfolio"><span>Portfolio</span></a></li>
<li><a href="https://www.blogger.com/blogger.g?blogID=630647630228661256#" title="Services"><span>Services</span></a></li>
<li><a href="https://www.blogger.com/blogger.g?blogID=630647630228661256#" title="About us"><span>About us</span></a></li>
<li><a href="https://www.blogger.com/blogger.g?blogID=630647630228661256#" title="Blog"><span>Blog</span></a></li>
</ul>
</div>
</body>
</html>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-58404943844921842962014-02-01T13:02:00.000+05:302014-02-04T14:24:45.237+05:30 Run client side .exe file from server side using asp.net <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<b><a href="http://codingcluster.blogspot.in/2014/02/run-client-side-exe-file-from-server.html" target="_blank"><o:p>Run .exe file by using </o:p>ActiveX controls from javascript:</a></b></div>
<div class="MsoNormal">
In one of my project my clients requirements is scanning a
document from local scanner and directly upload into the server through web
application. But there is no direct method to access local machine from sever
code in dot net, so we need some other solutions to access local .exe (to
activate scanner) file from server.<br />
<br />
Finally Google answering me "ActiveX0bject".
Yes we can run .exe file from server by using ActiveX shell command. Here is
the sample code to run client's side .exe file from server by using JavaScript and ActiveX0bject.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Enable ActiveX controls in IE for run .exe files from local :</div>
<div class="MsoNormal">
Before we enable
ActiveX in IE settings with the following simple steps, </div>
<div class="MsoNormal">
<b><span style="color: blue;">Step -1</span></b>: Open IE -->Tools --> Internet Options</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: blue;">Step -2</span></b>: Go to
security tab choose your zone (Internet (OR) Local) then click custom Level button</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<b><span style="color: blue;">Step-3</span></b>: Just set
"<b>The Initialize and script ActiveX controls not marked as safe</b>" as
"<b>Prompt</b>"</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-8gfs8F2shA0/UuyiR0g6KzI/AAAAAAAAAZI/gc5b7ZuJwq0/s1600/Run+exe+file+from++client+side+javascript.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-8gfs8F2shA0/UuyiR0g6KzI/AAAAAAAAAZI/gc5b7ZuJwq0/s1600/Run+exe+file+from++client+side+javascript.png" height="320" width="246" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Bk4Go-DpAbs/UuyiR-GOdAI/AAAAAAAAAZU/T8TcQ34Dvus/s1600/Enable+activex+controls+in+ie+for+run+exe+files+from+local+.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-Bk4Go-DpAbs/UuyiR-GOdAI/AAAAAAAAAZU/T8TcQ34Dvus/s1600/Enable+activex+controls+in+ie+for+run+exe+files+from+local+.png" height="320" width="281" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
And the following JavaScript code is for run .exe (In my case
"ImageScanner.exe")file with parameter session id, display order and user id.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: blue;">JavaScript Code </span></b></div>
<!-- Run .exe file from server side using asp.net --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">function</span> runScaningApp(sessId, disorder, userId){
<span style="color: blue;">var</span> shell=<span style="color: blue;">new</span> ActiveX0bject(<span style="color: #a31515;">"WScript.shell"</span>);
<span style="color: blue;">var</span> res = shell.run(<span style="color: #a31515;">'"ImageScanner.exe" "'</span>+ sessId +<span style="color: #a31515;">'" "'</span>+ disorder+<span style="color: #a31515;">'" "'</span>+ userId+<span style="color: #a31515;">'", '</span>1<span style="border: 1px solid #FF0000;">'</span>, <span style="color: blue;">true</span>);
<span style="color: blue;">if</span> (res == <span style="color: #a31515;">"0"</span>){
alert (<span style="color: #a31515;">"Your success message"</span>);
}
<span style="color: blue;">else</span>{
alert (<span style="color: #a31515;">"Sorry! Some error occurred"</span>);
}
}
</pre>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-61571098664345225772014-01-31T18:51:00.000+05:302014-01-31T18:52:17.699+05:30Multiple checkbox validation in asp .net mvc3 using jquery<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><html>
<head>
<script src=<span style="color: #a31515;">"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"</span>></script>
<script type=<span style="color: #a31515;">"text/javascript"</span>>
<span style="color: blue;">function</span> ValidateCheckBox()
{
<span style="color: blue;">var</span> selectedCheckBoxesValue = <span style="color: #a31515;">''</span>;
$(<span style="color: #a31515;">'#ValidateCheckBox'</span>).find(<span style="color: #a31515;">"input:checkbox.CheckBoxClassName:checked"</span>).each(<span style="color: blue;">function</span> (i, selected) {
<span style="color: blue;">if</span> (selectedCheckBoxesValue.length == 0) {
selectedCheckBoxesValue += $(selected).val();
}
<span style="color: blue;">else</span> {
selectedCheckBoxesValue += <span style="color: #a31515;">','</span> + $(selected).val();
}});
<span style="color: green;">// Here you also get all the comma separated values if you want else use below method for it</span>
<span style="color: blue;">if</span>(selectedCheckBoxesValue.length == 0)
{
alert(<span style="color: #a31515;">"Select atleast one checkbox"</span>);
}
}
</script>
</head>
<body>
<div id=<span style="color: #a31515;">"ValidateCheckBox"</span> style=<span style="color: #a31515;">"background-color:#0099FF; color:#FFFFFF; width:190;"</span>>
<table width=<span style="color: #a31515;">"200"</span> cellspacing=<span style="color: #a31515;">"2"</span> cellpadding=<span style="color: #a31515;">"2"</span>>
<tr>
<td><input type=<span style="color: #a31515;">"checkbox"</span> class=<span style="color: #a31515;">"CheckBoxClassName"</span>></td>
<td><label>Checkbox 1</label></td>
</tr>
<tr>
<td><input type=<span style="color: #a31515;">"checkbox"</span> class=<span style="color: #a31515;">"CheckBoxClassName"</span>></td>
<td><label>Checkbox 2</label></td>
</tr>
<tr>
<td><input type=<span style="color: #a31515;">"checkbox"</span> class=<span style="color: #a31515;">"CheckBoxClassName"</span>></td>
<td><label>Checkbox 3</label></td>
</tr>
<tr>
<td><input type=<span style="color: #a31515;">"checkbox"</span> class=<span style="color: #a31515;">"CheckBoxClassName"</span>></td>
<td><label>Checkbox 4</label></td>
</tr>
<tr>
<td><input type=<span style="color: #a31515;">"checkbox"</span> class=<span style="color: #a31515;">"CheckBoxClassName"</span>></td>
<td><label>Checkbox 5</label></td>
</tr>
<tr>
<td colspan=<span style="color: #a31515;">"2"</span>><input type=<span style="color: #a31515;">"button"</span> onClick=<span style="color: #a31515;">"ValidateCheckBox();"</span> value=<span style="color: #a31515;">"Validate checkbox"</span>></td>
</tr>
</table>
</div>
</body>
</html>
</pre>
</div>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
function ValidateCheckBox()
{
var selectedCheckBoxesValue = '';
$('#ValidateCheckBox').find("input:checkbox.CheckBoxClassName:checked").each(function (i, selected) {
if (selectedCheckBoxesValue.length == 0) {
selectedCheckBoxesValue += $(selected).val();
}
else {
selectedCheckBoxesValue += ',' + $(selected).val();
}});
// Here you also get all the comma separated values if you want else use below method for it
if(selectedCheckBoxesValue.length == 0)
{
alert("Select atleast one checkbox");
}
}
</script>
</head>
<body>
<div id="ValidateCheckBox" style="background-color: #0099ff; color: white; width: 190;">
<table cellpadding="2" cellspacing="2" style="width: 200px;">
<tr>
<td><input class="CheckBoxClassName" type="checkbox" /></td>
<td><label>Checkbox 1</label></td>
</tr>
<tr>
<td><input class="CheckBoxClassName" type="checkbox" /></td>
<td><label>Checkbox 2</label></td>
</tr>
<tr>
<td><input class="CheckBoxClassName" type="checkbox" /></td>
<td><label>Checkbox 3</label></td>
</tr>
<tr>
<td><input class="CheckBoxClassName" type="checkbox" /></td>
<td><label>Checkbox 4</label></td>
</tr>
<tr>
<td><input class="CheckBoxClassName" type="checkbox" /></td>
<td><label>Checkbox 5</label></td>
</tr>
<tr>
<td colspan="2"><input onclick="ValidateCheckBox();" type="button" value="Validate checkbox" /></td>
</tr>
</table>
</div>
</body>
</html>
<br />
<a href="http://3.bp.blogspot.com/-r6EwuwWyf9w/Uuuh_raYXuI/AAAAAAAAAY4/meTcYcS4FGo/s1600/Multi+checkbox+validation+in+mvc3+using+jquery.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="http://3.bp.blogspot.com/-r6EwuwWyf9w/Uuuh_raYXuI/AAAAAAAAAY4/meTcYcS4FGo/s1600/Multi+checkbox+validation+in+mvc3+using+jquery.png" height="226" width="320" /></a>
</div>Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-83378899210190331832013-12-10T17:02:00.000+05:302013-12-11T17:38:01.880+05:30drag and drop between two divs using jquery ui<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://codingcluster.blogspot.in/2013/12/drag-and-drop-between-two-divs-using.html" target="_blank">Jquery drag and drop sortable between different divs:</a><br />
In this tutorial I'm using jquery 1.4 2 min js and jquery-ui-1.8.13.min.js for drag and drop divs with image. In this simaple example you can Drag and drop items within a list and also Drag and drop items within and between lists of divs<br />
First download the requirement Jquey fils, you can download it from here or you can directly call from google.<br />
<br />
<a href="http://4.bp.blogspot.com/-ltR3NA3au4U/Uqb6N7ECBFI/AAAAAAAAAYQ/T_Pjq4cmDCA/s1600/drag+and+drop+div+using+jquery+coiding+cluster.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-ltR3NA3au4U/Uqb6N7ECBFI/AAAAAAAAAYQ/T_Pjq4cmDCA/s1600/drag+and+drop+div+using+jquery+coiding+cluster.png" height="140" width="200" /></a><br />
<br />
<br />
<br />
Download <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" target="_blank">jquery 1.4 2 min js</a><br />
<br />
Download<a href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" target="_blank">jquery-ui-1.8.13.min.js</a><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Using the parameter connectWith (jQuery selector) we can define which other lists that items within a list can be dragged and dropped to. Add the following code into page load function.<br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><script>
$(document).ready(<span style="color: blue;">function</span> () {
$(<span style="color: #a31515;">'.container .draggable-list'</span>).sortable({
connectWith: <span style="color: #a31515;">'.container .draggable-list'</span>
});
});
</script>
</pre>
</div>
<br />
then add that js reference to your page header tag<br />
<!-- coding cluster -->
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"> <script type=<span style="color: #a31515;">"text/javascript"</span> src=<span style="color: #a31515;">"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"</span>></script>
<script type=<span style="color: #a31515;">"text/javascript"</span> src=<span style="color: #a31515;">"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"</span>></script>
</pre>
</div>
<br />
Then copy and paste the following css in to your style region
<!-- Jquery drag and drop div-->
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><style>
<span style="color: #2b91af;">.container</span> {
<span style="color: blue;">width</span>: 400px;
<span style="color: blue;">background-color</span>:#000000;
<span style="color: blue;">border-bottom-color</span>:#003366;
}
<span style="color: #2b91af;">.draggable-list</span> {
<span style="color: blue;">background-color</span>: #0066FF;
<span style="color: blue;">list-style</span>: <span style="color: blue;">none</span>;
<span style="color: blue;">margin</span>: 0;
<span style="color: blue;">min-height</span>: 70px;
<span style="color: blue;">padding</span>: 10px;
}
<span style="color: #2b91af;">.draggable-item</span> {
<span style="color: blue;">background-color</span>: #FFF;
<span style="color: blue;">border</span>: 1px <span style="color: blue;">dotted</span> #000;
<span style="color: blue;">cursor</span>: move;
<span style="color: blue;">display</span>: <span style="color: blue;">block</span>;
<span style="color: blue;">font-weight</span>: <span style="color: blue;">bold</span>;
<span style="color: blue;">color</span>:#CC0033;
<span style="color: blue;">text-shadow</span>: 5px 5px 5px #FF0000;
<span style="color: blue;">padding-bottom</span>: 70px;
<span style="color: blue;">margin</span>: 5px;
}
<span style="color: #2b91af;">.img1</span> {
<span style="color: blue;">width</span>:76px;
<span style="color: blue;">height</span>: 62px;
<span style="color: blue;">background</span>:<span style="color: #a31515;">url('http://2.bp.blogspot.com/-WdEtllcSgUw/UqXHu0jQ4QI/AAAAAAAAAYA/T6SK2apzY10/s1600/how+to+use+sprite+image.jpg')</span> -3.5px -9px;
<span style="color: blue;">float</span>:<span style="color: blue;">left</span>;
}
<span style="color: #2b91af;">.img2</span> {
<span style="color: blue;">background</span>:<span style="color: #a31515;">url('http://2.bp.blogspot.com/-WdEtllcSgUw/UqXHu0jQ4QI/AAAAAAAAAYA/T6SK2apzY10/s1600/how+to+use+sprite+image.jpg')</span> -98px -7px;
<span style="color: blue;">width</span>: 70px;
<span style="color: blue;">height</span>: 66px;
<span style="color: blue;">float</span>:<span style="color: blue;">left</span>;
}
<span style="color: #2b91af;">.img3</span> {
<span style="color: blue;">background</span>:<span style="color: #a31515;">url('http://2.bp.blogspot.com/-WdEtllcSgUw/UqXHu0jQ4QI/AAAAAAAAAYA/T6SK2apzY10/s1600/how+to+use+sprite+image.jpg')</span> -198px -9px;
<span style="color: blue;">width</span>: 63px;
<span style="color: blue;">height</span>: 58px;
<span style="color: blue;">float</span>:<span style="color: blue;">left</span>;
}
</pre>
</div>
Finally add the draggable-list and draggable-item with in the container div.
<!-- Online demo for jquery drag and drop -->
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"container"</span><span style="color: green; font-weight: bold;">></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-list"</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:left"</span><span style="color: green; font-weight: bold;">></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img1"</span><span style="color: green; font-weight: bold;">></div></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group A <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img2"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group A <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img3"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group A <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img5"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group A <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img6"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group A <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img4"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group A <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-list"</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img7"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group B <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img8"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group B <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img9"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group B <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img10"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group B <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img11"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group B <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"><div</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"draggable-item"</span><span style="color: green; font-weight: bold;">></span> <span style="color: green; font-weight: bold;"><span</span> <span style="color: #7d9029;">class=</span><span style="color: #ba2121;">"img12"</span><span style="color: green; font-weight: bold;">></span></span>
<span style="color: green; font-weight: bold;"><p</span> <span style="color: #7d9029;">style=</span><span style="color: #ba2121;">"float:right"</span><span style="color: green; font-weight: bold;">></span> Group B <span style="color: green; font-weight: bold;"></p></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"></div></span>
<span style="color: green; font-weight: bold;"></div></span>
</pre>
</div>
<br />
<div id="actions">
<a alt="jquery drag and drop demo" class="css3button shape-2 blue effect-5" href="http://jsfiddle.net/codingcluster/6hMZX/4/" target="_blank">Demo</a><a alt="jquery drag and drop download" class="css3button shape-2 blue effect-5" href="https://app.box.com/s/advb4g4t2fosymen9lgg" target="_blank">Download</a></div>
</div>
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-84053075161772279272013-11-28T13:05:00.002+05:302013-12-13T16:06:30.732+05:30Enabling Service Broker in SQL Server 2008<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<b><a href="http://codingcluster.blogspot.in/2013/11/enabling-service-broker-in-sql-server.html" target="_blank">Activate Service Broker in SQL Server 2008:</a></b><br />
If you are working in sql dependency, SignalR related projects you must enable service broker for messaging and queuing functions between instances. The basic functions of sending and receiving messages forms a part of a “conversation.”<br />
<br />
<b><a href="http://codingcluster.blogspot.in/2013/11/enabling-service-broker-in-sql-server.html" target="_blank">What is services broker?</a></b></div>
<div class="MsoNormal">
According from
Microsoft SQL Server Service Broker provides native support for messaging and
queuing applications in the SQL Server Database Engine. This makes it easier
for developers to create sophisticated applications that use the Database
Engine components to communicate between disparate databases. Developers can
use Service Broker to easily build distributed and reliable applications.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Service broker find applications when single or multiple SQL
server instances are used. This functionality helps in sending messages to
remote databases on different servers and processing of the messages within a
single database. In order to send messages between the instances, the Service
Broker uses TCP/IP.</div>
<br />
<div class="MsoNormal">
<b>Check the sql server services broker status?</b><br />
<div class="MsoNormal">
Before enable service broker better we need check the current services broker status
of the database. The following simple command used to do that.</div>
</div>
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: green; font-weight: bold;">SELECT</span> name, is_broker_enabled <span style="color: green; font-weight: bold;">FROM</span> sys.databases
</pre>
</div>
<br />
<div class="MsoNormal">
Then activate services broker on "codingclusterDB"
database by using the following command.</div>
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: green; font-weight: bold;">ALTER</span> <span style="color: green; font-weight: bold;">DATABASE</span> CodingClusterDB <span style="color: green; font-weight: bold;">SET</span> ENABLE_BROKER
<span style="color: green; font-weight: bold;">GO</span>
</pre>
</div>
<br />
<div class="MsoNormal">
<b>Enable SQL Server Broker taking too long time?</b></div>
<div class="MsoNormal">
If your Alter Database query takes long time to process,
then use the following command to activate services broker on your database<span style="background: white; color: #444444; font-family: "Helvetica","sans-serif"; font-size: 10.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: green; font-weight: bold;">ALTER</span> <span style="color: green; font-weight: bold;">DATABASE</span> CodingClusterDB <span style="color: green; font-weight: bold;">SET</span> ENABLE_BROKER <span style="color: green; font-weight: bold;">WITH</span> <span style="color: green; font-weight: bold;">ROLLBACK</span> <span style="color: green; font-weight: bold;">IMMEDIATE</span>;
<span style="color: green; font-weight: bold;">GO</span>
</pre>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-78083075430765656482013-11-26T18:39:00.002+05:302013-11-26T18:44:26.609+05:30Install .nupkg file locally(OR)Offline in visual studio from NuGet<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2013/11/install-nupkg-file-locallyoroffline-in.html" target="_blank">Install NuGet Package from local machine manually:</a></b><br />
<div class="MsoNormal">
Some companies not allowed internet connection for
development environment for some security purpose. On that time we can't
install packages directly from
Nuget.Org through Package Manager console. This type of
situation the following s three easy steps to install Nuget packages to visual
studio when your are working in offline mode.</div>
<br />
<div class="MsoNormal">
<b><span style="color: blue;">Step-1:</span></b> First download your package from <a href="http://www.nuget.org/packages/">http://www.nuget.org/packages/</a> . </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<a href="http://codingcluster.blogspot.in/2013/11/install-nupkg-file-locallyoroffline-in.html" target="_blank">Download Nuget Packages Without VS/NuGet Package Manager (Manuallydownload): </a><br />
If you not able to directly download the package from <a href="http://www.nuget.org/packages/">http://www.nuget.org/packages/</a> , then
you try a chrome extension called "<span style="color: #303942; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; line-height: 115%;">NuTake</span>". This extension create a direct link to
download the package. The link just shown
under the "PM>Install - Package..." command box.</div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-NB1NIfh3yJM/UpSbiv032mI/AAAAAAAAAXY/Q6oXAb5FuaI/s1600/download_nuget_packages_mannually.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-NB1NIfh3yJM/UpSbiv032mI/AAAAAAAAAXY/Q6oXAb5FuaI/s1600/download_nuget_packages_mannually.png" height="180" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: blue;">Step-2: </span></b>After download your package open visual studio and
open "<strong><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; border: 1pt none windowtext; font-family: Arial, sans-serif; font-size: 10.5pt; line-height: 115%; padding: 0in;">Tools - > Options ->
Package Manager"<o:p></o:p></span></strong></div>
<div class="MsoNormal">
<strong><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; border: 1pt none windowtext; font-family: Arial, sans-serif; font-size: 10.5pt; line-height: 115%; padding: 0in;"><br /></span></strong></div>
<div class="MsoNormal">
<strong><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; border: 1pt none windowtext; font-family: Arial, sans-serif; font-size: 10.5pt; line-height: 115%; padding: 0in;"> </span></strong></div>
<div class="separator" style="clear: both; text-align: center;">
<strong><a href="http://1.bp.blogspot.com/-UAf0jlPCyO8/UpSb1zpqq5I/AAAAAAAAAXg/ojUoDwEPQlA/s1600/Add_Nuget_Package_source_offline.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-UAf0jlPCyO8/UpSb1zpqq5I/AAAAAAAAAXg/ojUoDwEPQlA/s1600/Add_Nuget_Package_source_offline.png" height="179" width="320" /></a></strong></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="MsoNormal">
Give a name and folder location. Click OK. Drop your NuGet
package files in that folder.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-X9_suuLepV4/UpSb2LoYsPI/AAAAAAAAAXw/nkt5E1clT-c/s1600/Install+NuGet+Package+locally.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-X9_suuLepV4/UpSb2LoYsPI/AAAAAAAAAXw/nkt5E1clT-c/s1600/Install+NuGet+Package+locally.png" height="179" width="320" /></a></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<b><span style="color: blue;">Step-3:</span></b> In the third step, Go to your Project, Right click
and select "Manage Nuget Packages" and </div>
<br />
<div class="MsoNormal">
select /Install your
new Package source.</div>
<div class="MsoNormal">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ZOm3FotRiBc/UpSb2V5o6JI/AAAAAAAAAX0/JQ1Cz9YtBqA/s1600/Install+NuGet+Package+manually.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-ZOm3FotRiBc/UpSb2V5o6JI/AAAAAAAAAX0/JQ1Cz9YtBqA/s1600/Install+NuGet+Package+manually.png" height="179" width="320" /></a></div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-46949494532533492282013-11-15T11:54:00.000+05:302013-12-13T16:08:44.126+05:30Sample code for displaying festival names on calendar control in ASP.Net<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://codingcluster.blogspot.in/2013/11/sample-code-for-displaying-festival.html" target="_blank"><b>Displaying festival names on calendar control using c# in ASP.Net:</b></a><br />
<br />
This is an article for showing festival names on a specific date on calendar control. First create a SQL table with following fields HolidayName, HolidayDate. And fulfill the festival name in "HolidayName" field and festival date in "HolidayDate" field.<br />
<br />
Then took one Calendar control on to the page(Calendar.aspx)<br />
<br />
Copy and paste the following code into your Calendar.aspx file<br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"> <span style="color: #007700;"><form</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"form1"</span> <span style="color: #0000cc;">runat=</span><span style="background-color: #fff0f0;">"server"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><div></span>
<span style="color: #007700;"><asp:calendar</span> <span style="color: #0000cc;">ondayrender=</span><span style="background-color: #fff0f0;">"Calendar1_DayRender"</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"Calendar1"</span> <span style="color: #0000cc;">runat=</span><span style="background-color: #fff0f0;">"server"</span> <span style="color: #0000cc;">backcolor=</span><span style="background-color: #fff0f0;">"#FFFFCC"</span> <span style="color: #0000cc;">bordercolor=</span><span style="background-color: #fff0f0;">"#FFCC66"</span> <span style="color: #0000cc;">borderwidth=</span><span style="background-color: #fff0f0;">"1px"</span> <span style="color: #0000cc;">daynameformat=</span><span style="background-color: #fff0f0;">"Shortest"</span> <span style="color: #0000cc;">names=</span><span style="background-color: #fff0f0;">"Verdana"</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"8pt"</span> <span style="color: #0000cc;">forecolor=</span><span style="background-color: #fff0f0;">"#663399"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"200px"</span> <span style="color: #0000cc;">showgridlines=</span><span style="background-color: #fff0f0;">"True"</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"300px"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><selecteddaystyle</span> <span style="color: #0000cc;">backcolor=</span><span style="background-color: #fff0f0;">"#CCCCFF"</span> <span style="color: #0000cc;">bold=</span><span style="background-color: #fff0f0;">"True"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><selectorstyle</span> <span style="color: #0000cc;">backcolor=</span><span style="background-color: #fff0f0;">"#FFCC66"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><todaydaystyle</span> <span style="color: #0000cc;">backcolor=</span><span style="background-color: #fff0f0;">"#FFCC66"</span> <span style="color: #0000cc;">forecolor=</span><span style="background-color: #fff0f0;">"White"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><othermonthdaystyle</span> <span style="color: #0000cc;">forecolor=</span><span style="background-color: #fff0f0;">"#CC9966"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><nextprevstyle</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"9pt"</span> <span style="color: #0000cc;">forecolor=</span><span style="background-color: #fff0f0;">"#FFFFCC"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><dayheaderstyle</span> <span style="color: #0000cc;">backcolor=</span><span style="background-color: #fff0f0;">"#FFCC66"</span> <span style="color: #0000cc;">bold=</span><span style="background-color: #fff0f0;">"True"</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"1px"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><titlestyle</span> <span style="color: #0000cc;">backcolor=</span><span style="background-color: #fff0f0;">"#990000"</span> <span style="color: #0000cc;">bold=</span><span style="background-color: #fff0f0;">"True"</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"9pt"</span> <span style="color: #0000cc;">forecolor=</span><span style="background-color: #fff0f0;">"#FFFFCC"</span><span style="color: #007700;">></span>
<span style="color: #007700;"></titlestyle></span>
<span style="color: #007700;"></dayheaderstyle></nextprevstyle></othermonthdaystyle></todaydaystyle></selectorstyle></selecteddaystyle></asp:calendar></div></span>
<span style="color: #007700;"></form></span>
<span style="color: #007700;"><span</span> <span style="color: #0000cc;">style=</span><span style="background-color: #fff0f0;">"font-weight: bold; color: rgb(51, 51, 255);font-size:130%;"</span><span style="color: #007700;">></span></span>
</pre>
</div>
<br />
<br />
Then Copy and paste the following code into your Calendar.aspx.cs file<br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Configuration;
<span style="color: blue;">using</span> System.Data;
<span style="color: blue;">using</span> System.Linq;
<span style="color: blue;">using</span> System.Web;
<span style="color: blue;">using</span> System.Web.Security;
<span style="color: blue;">using</span> System.Web.UI;
<span style="color: blue;">using</span> System.Web.UI.HtmlControls;
<span style="color: blue;">using</span> System.Web.UI.WebControls;
<span style="color: blue;">using</span> System.Web.UI.WebControls.WebParts;
<span style="color: blue;">using</span> System.Xml.Linq;
<span style="color: blue;">using</span> System.Data.SqlClient;
<span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">_Default</span> : System.Web.UI.Page
{
SqlConnection con;
<span style="color: blue;">protected</span> <span style="color: blue;">void</span> Page_Load(<span style="color: #2b91af;">object</span> sender, EventArgs e)
{
con = <span style="color: blue;">new</span> SqlConnection(ConfigurationManager.ConnectionStrings[<span style="color: #a31515;">"YourConnectionString"</span>].ConnectionString);
}
<span style="color: blue;">protected</span> <span style="color: blue;">void</span> Calendar1_DayRender(<span style="color: #2b91af;">object</span> sender, DayRenderEventArgs e)
{
CalendarDay day = (CalendarDay)e.Day;
SqlCommand cmd = <span style="color: blue;">new</span> SqlCommand(<span style="color: #a31515;">"select HolidayName,HolidayDate from Holidays"</span>, con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
<span style="color: blue;">while</span> (dr.Read())
{
<span style="color: blue;">if</span> (day.Date.ToString() == dr[<span style="color: #a31515;">"HolidayDate"</span>].ToString())
{
TableCell cell = (TableCell)e.Cell;
<span style="color: #2b91af;">string</span> s1 = dr[<span style="color: #a31515;">"HolidayName"</span>].ToString();
<span style="color: blue;">if</span> (s1 != <span style="color: blue;">null</span>)
{
cell.BackColor = System.Drawing.Color.LightGray;
cell.Controls.Add(<span style="color: blue;">new</span> LiteralControl(<span style="color: #a31515;">"</span>
<span style="color: #a31515;">" + s1));</span>
}
}
}
con.Close();
}
}
</pre>
</div>
That's all finally build and run your page you will see a calender control with festival name.
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-72JFLpLdH5E/TjrXcjk5NWI/AAAAAAAAACM/0r8YwhdAdV0/s320/cal3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-72JFLpLdH5E/TjrXcjk5NWI/AAAAAAAAACM/0r8YwhdAdV0/s320/cal3.jpg" /></a></div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-41183522549838430442012-12-21T07:11:00.001+05:302012-12-21T07:13:27.096+05:30Drop All tables in Oracle using SQL Statement<div dir="ltr" style="text-align: left;" trbidi="on">
<!-- c# blog coding cluster www.codingcluster.blogspot.com -->
<b><a href="http://codingcluster.blogspot.in/2012/12/drop-all-tables-in-oracle-using-sql.html" target="_blank">Dropping all user tables in Oracle:</a></b><br />
Sometime for developer want drop all table, and this is the working example that I'm used.<br />
<br />
Note:
<br />
<ul style="text-align: left;">
<li> You need to log in to that user which you wanted to drop the tables</li>
<li> Keep in mind, If run, it will not able to rollback</li>
</ul>
<br />
<b><span style="color: blue;">Here is the SQL Script:</span></b><br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">BEGIN</span>
<span style="color: blue;">FOR</span> cur_rec <span style="color: blue;">IN</span> (<span style="color: blue;">SELECT</span> object_name, object_type
<span style="color: blue;">FROM</span> user_objects
<span style="color: blue;">WHERE</span> object_type <span style="color: blue;">IN</span>
(<span style="color: #a31515;">'TABLE'</span>,
<span style="color: #a31515;">'VIEW'</span>,
<span style="color: #a31515;">'PACKAGE'</span>,
<span style="color: #a31515;">'PROCEDURE'</span>,
<span style="color: #a31515;">'FUNCTION'</span>,
<span style="color: #a31515;">'SEQUENCE'</span>
))
<span style="color: blue;">LOOP</span>
<span style="color: blue;">BEGIN</span>
<span style="color: blue;">IF</span> cur_rec.object_type = <span style="color: #a31515;">'TABLE'</span>
<span style="color: blue;">THEN</span>
<span style="color: blue;">EXECUTE</span> <span style="color: blue;">IMMEDIATE</span> <span style="color: #a31515;">'DROP '</span>
|| cur_rec.object_type
|| <span style="color: #a31515;">' "'</span>
|| cur_rec.object_name
|| <span style="color: #a31515;">'" CASCADE CONSTRAINTS'</span>;
<span style="color: blue;">ELSE</span>
<span style="color: blue;">EXECUTE</span> <span style="color: blue;">IMMEDIATE</span> <span style="color: #a31515;">'DROP '</span>
|| cur_rec.object_type
|| <span style="color: #a31515;">' "'</span>
|| cur_rec.object_name
|| <span style="color: #a31515;">'"'</span>;
<span style="color: blue;">END</span> <span style="color: blue;">IF</span>;
<span style="color: blue;">EXCEPTION</span>
<span style="color: blue;">WHEN</span> OTHERS
<span style="color: blue;">THEN</span>
DBMS_OUTPUT.put_line ( <span style="color: #a31515;">'FAILED: DROP '</span>
|| cur_rec.object_type
|| <span style="color: #a31515;">' "'</span>
|| cur_rec.object_name
|| <span style="color: #a31515;">'"'</span>
);
<span style="color: blue;">END</span>;
<span style="color: blue;">END</span> <span style="color: blue;">LOOP</span>;
<span style="color: blue;">END</span>;
</pre>
</div>
I got this solution from
http://stackoverflow.com/questions/1690404/how-to-drop-all-user-tables
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-59082388126724197632012-12-21T06:49:00.000+05:302012-12-21T07:12:20.264+05:30Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://codingcluster.blogspot.in/2012/12/error-18452-login-failed-for-user-null.html" target="_blank"><b>SQL Server connection Error: 18452 Login failed for user ‘(null)’.</b></a><br />
<br />
I had an error that I believe a lot of new user for SQL server may face during create a new Database.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ltdxoyldhBo/UNO4fACdfPI/AAAAAAAAAWc/wsdVq3JOPL0/s1600/sql-Error-18452-Login-failed.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="88" src="http://1.bp.blogspot.com/-ltdxoyldhBo/UNO4fACdfPI/AAAAAAAAAWc/wsdVq3JOPL0/s320/sql-Error-18452-Login-failed.jpg" width="320" /></a></div>
<br />
<br />
Below is the solution that I'm used to resolve my issue<br />
<br />
Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)”<br />
to “Mixed Mode (Windows Authentication and SQL Server Authentication)”.<br />
<br />
Run following script in SQL Analyzer to change the authentication<br />
<br />
LOGIN sa ENABLE<br />
GO<br />
ALTER LOGIN sa WITH PASSWORD = ‘’<br />
GO<br />
<br />
OR<br />
<br />
In Object Explorer, expand Security, expand Logins, right-click 'sa', and then click Properties. On the General page, you may have to create and confirm a password for the 'sa' login. On the Status page, in the Login section, click Enabled, and then click OK.</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-66115220224723231272012-12-10T21:44:00.000+05:302012-12-12T23:08:58.398+05:30Select one checkbox from group of checkbox using jquery<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 1.3;"><a href="http://codingcluster.blogspot.in/2012/12/select-one-checkbox-from-group-of.html" target="_blank"><b>Multiple Checkbox validation in asp.net mvc 3 using jquery:</b></a></span><br />
<div>
<br /></div>
<div>
This is the sample code for select only one check box from a check box group.<br />
<br /></div>
<!--Select one checkbox from group of checkbox using jquery http://codingcluster.blogspot.in --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;">function ValidateChkBox()
{
<span style="color: #2b91af;">var</span> selectedCheckBoxesValue = '';
$('#DIVID').find(<span style="color: #a31515;">"input:checkbox.CheckBoxClassName:checked"</span>).each(function (i, selected) {
<span style="color: blue;">if</span> (selectedCheckBoxesValue.length == 0) {
selectedCheckBoxesValue += $(selected).val();
}
<span style="color: blue;">else</span> {
selectedCheckBoxesValue += <span style="color: #a31515;">','</span> + $(selected).val();
}});
<span style="color: green;">// Here you also get all the comma separated values if you want else use below method for it</span>
<span style="color: blue;">if</span>(selectedCheckBoxesValue.length == 0)
{
alert(<span style="color: #a31515;">"Select atleast one checkbox"</span>);
}
}
</pre>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-59547463064735534452012-10-15T23:49:00.002+05:302012-10-15T23:51:50.493+05:30Offline storage using Indexeddb / browsers to support IndexedDb<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/10/offline-storage-using-indexeddb.html" target="_blank">What is IndexedDB?</a></b><br />
An IndexedDB is basically a persistent data store in the browser — a database on the client side(offline storage). Like regular relational databases, it maintains indexes over the records it stores and developers use the IndexedDB JavaScript API to locate records by key or by looking up an index.<br />
<br />
IndexedDB API is a specification for an index database which exists in the browser. The IndexedDB is made of records holding simple values and hierarchical objects. Each of the records consists of a key path and a corresponding value which can be a simple type like string or date and more advance types like JavaScript objects and arrays. It can include indexes for faster retrieval of records and can store large amount of objects.<br />
<br />
<b><a href="http://codingcluster.blogspot.in/2012/10/offline-storage-using-indexeddb.html" target="_blank">Which browsers (chrome/opera/firefox/IE...) to support IndexedDb?</a></b><br />
<br />
Preliminary support for Indexed DB is included by Firefox (since version 4), Google Chrome (since version 11), and by the Internet Explorer 10 Consumer Preview and Metro style apps.<br />
Safari, Chrome 4 and Opera support an alternate mechanism for client-side database storage called Web SQL Database.<br />
<br />
Summary of browsers with full support.<br />
<br />
Chrome: Version 11 onward<br />
<br />
Opera: No current or planned support<br />
<br />
Firefox: Version 4 onward<br />
<br />
For good measure, IE: Version 10 onward<br />
<br />
Compatibility table for support of IndexedDB in desktop and mobile browsers.<br />
<br />
<a href="http://caniuse.com/indexeddb">http://caniuse.com/indexeddb</a><br />
<br />
<br />
If you new to indexedDB concept you must know about the following concepts,<br />
<a href="http://3.bp.blogspot.com/-ZTCK9xVi8C0/UHxS5HPVNPI/AAAAAAAAAS0/ejkEXJkP6iE/s1600/indexeddb-codingcluster.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-ZTCK9xVi8C0/UHxS5HPVNPI/AAAAAAAAAS0/ejkEXJkP6iE/s1600/indexeddb-codingcluster.png" /></a><br />
WHAT IS INDEXEDDB?<br />
<br />
WHY INDEXEDDB?<br />
<br />
How to Opening the database in indexedDB?<br />
<br />
INDEXEDDB - Creating an object store<br />
<br />
ADDING DATA TO AN OBJECT STORE Adding data to an object store<br />
<br />
QUERYING THE DATA IN A STORE.<br />
<br />
RENDERING DATA FROM AN OBJECT STORE<br />
<br />
DELETING DATA FROM A TABLE<br />
<br />
for all above questions <b><a href="http://www.html5rocks.com/en/tutorials/indexeddb/todo/" target="_blank">html5rocks </a></b>have the solution with live demo<br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-44065046644044536862012-10-10T23:15:00.000+05:302012-10-13T00:09:52.079+05:30Fading / Blinking rounded corner button only with pure css(without image)<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/10/fadeblinking-rounded-corner-button-only.html" target="_blank">Css only Rounded corners Opacity Gradient buttons:</a></b><br />
This is the source code for, No JavaScript, No Images, No Flash - CSS Only! Blinking round corner button.<br />
<div>
<br />
<div>
<b><span style="color: blue;"><a href="http://codingcluster.blogspot.in/2012/10/fadeblinking-rounded-corner-button-only.html" target="_blank">source code for css only rounded corner fade button</a></span></b><span style="color: #222222; font-family: arial, sans-serif; font-size: x-small;"><span style="line-height: 16px;"><!-- http://codingcluster.blogspot.in/ --></span></span><br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: arial, sans-serif; font-size: x-small;"><span style="line-height: 16px;"><span style="color: #990000;"><html><head>
<style></span><span style="color: #222222;">
nav a#blink {
</span><span style="color: blue;">padding</span><span style="color: #222222;">: 10px 10px;
</span><span style="color: blue;">margin-right</span><span style="color: #222222;">: 10px;
</span><span style="color: blue;">margin-bottom</span><span style="color: #222222;">: 5px;
</span><span style="color: blue;">border</span><span style="color: #222222;">-radius:20px;
</span><span style="color: blue;">display</span><span style="color: #222222;">: </span><span style="color: blue;">inline</span><span style="color: #222222;">-</span><span style="color: blue;">block</span><span style="color: #222222;">;
</span><span style="color: blue;">color</span><span style="color: #222222;">: #421f00;
</span><span style="color: blue;">background-color</span><span style="color: #222222;">:#e6a560;
</span><span style="color: blue;">background</span><span style="color: #222222;">: -moz-linear-gradient(
</span><span style="color: blue;">top</span><span style="color: #222222;">,
#e6a560 0%,
#ca6609);
</span><span style="color: blue;">background</span><span style="color: #222222;">: -</span><span style="border: 1px solid rgb(255, 0, 0); color: #222222;">o</span><span style="color: #222222;">-linear-gradient(
</span><span style="color: blue;">top</span><span style="color: #222222;">,
#e6a560 0%,
#ca6609);
</span><span style="color: blue;">background</span><span style="color: #222222;">: -webkit-gradient(
linear, </span><span style="color: blue;">left</span><span style="color: #222222;"> </span><span style="color: blue;">top</span><span style="color: #222222;">, </span><span style="color: blue;">left</span><span style="color: #222222;"> </span><span style="color: blue;">bottom</span><span style="color: #222222;">,
from(#e6a560),
to(#ca6609));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=</span><span style="color: #a31515;">'#e6a560'</span><span style="color: #222222;">, endColorstr=</span><span style="color: #a31515;">'#ca6609'</span><span style="color: #222222;">);
</span><span style="color: blue;">border</span><span style="color: #222222;">-radius: 5px;
-moz-</span><span style="color: blue;">border</span><span style="color: #222222;">-radius: 5px;
-webkit-</span><span style="color: blue;">border</span><span style="color: #222222;">-radius: 5px;
</span><span style="color: blue;">border</span><span style="color: #222222;">: 1px </span><span style="color: blue;">solid</span><span style="color: #222222;"> #ffd5ab;
-moz-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
</span><span style="color: blue;">inset</span><span style="color: #222222;"> 0px 0px 2px rgba(66,31,0,0.7);
-webkit-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
</span><span style="color: blue;">inset</span><span style="color: #222222;"> 0px 0px 2px rgba(66,31,0,0.7);
</span><span style="color: blue;">text-shadow</span><span style="color: #222222;">:
0px -1px 0px rgba(171,87,13,0.4),
0px 1px 0px rgba(255,255,255,0.3);
</span><span style="color: blue;">opacity</span><span style="color: #222222;">:0.7;
-webkit-animation-name: buttonPulse;
-webkit-animation-duration: 4s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
</span><span style="color: blue;">@-webkit-keyframes</span><span style="color: #222222;"> buttonPulse {
0% { </span><span style="color: blue;">opacity</span><span style="color: #222222;">: 0.5 }
50% { </span><span style="color: blue;">opacity</span><span style="color: #222222;">: 1 }
100% { </span><span style="color: blue;">opacity</span><span style="color: #222222;">: 0.5 }
}
</span><span style="color: #990000;"></style>
</head>
<body></span><span style="color: #222222;">
<nav role=</span><span style="color: #a31515;">"navigation"</span><span style="color: #222222;">>
<a href=</span><span style="color: #a31515;">"</span></span></span><a href="http://codingcluster.blogspot.in/2012/10/fadeblinking-rounded-corner-button-only.html">http://codingcluster.blogspot.in/2012/10/fadeblinking-rounded-corner-button-only.html</a><span style="font-family: arial, sans-serif; font-size: x-small;"><span style="line-height: 16px;"><span style="color: #a31515;">"</span><span style="color: #222222;"> id=</span><span style="color: #a31515;">"blink"</span><span style="color: #222222;">>Hay Look at my skin</a>
</span><span style="color: #990000;"></nav></span><span style="color: #222222;">
</span><span style="color: #990000;"></body>
</html></span><span style="color: #222222;">
</span></span></span></pre>
</div>
<span style="color: #222222; font-family: arial, sans-serif; font-size: x-small;"><span style="line-height: 16px;">
</span></span></div>
<br />
<b><span style="color: blue;">Demo:
</span></b><br />
<b><span style="color: blue;"><br /></span></b>
<html><head>
<style>
nav a#blink {
padding: 10px 10px;
margin-right: 10px;
margin-bottom: 5px;
border-radius:20px;
display: inline-block;
color: #421f00;
background-color:#e6a560;
background: -moz-linear-gradient(
top,
#e6a560 0%,
#ca6609);
background: -o-linear-gradient(
top,
#e6a560 0%,
#ca6609);
background: -webkit-gradient(
linear, left top, left bottom,
from(#e6a560),
to(#ca6609));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6a560', endColorstr='#ca6609');
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #ffd5ab;
-moz-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 2px rgba(66,31,0,0.7);
-webkit-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 2px rgba(66,31,0,0.7);
text-shadow:
0px -1px 0px rgba(171,87,13,0.4),
0px 1px 0px rgba(255,255,255,0.3);
opacity:0.7;
-webkit-animation-name: buttonPulse;
-webkit-animation-duration: 4s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
@-webkit-keyframes buttonPulse {
0% { opacity: 0.5 }
50% { opacity: 1 }
100% { opacity: 0.5 }
}
</style>
</head>
<body>
<nav role="navigation">
<a href="http://www.blogger.com/blogger.g?blogID=630647630228661256#" id="blink">Look at my skin</a>
</nav>
</body>
</html>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-15456884079878150742012-10-05T00:20:00.000+05:302012-10-05T00:27:36.450+05:30MVC 3: Bind View page with more than two model classes<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/10/mvc-3-bind-view-page-with-more-than-two.html" target="_blank">ASP.NET MVC 3: How to call two model class in to a single view(.cshtml)</a></b><br />
This is the sample code for load two model class in to a single view in asp.net mvc 3. To do this you just create a composite class with both objects as its properties:<br />
<br />
<b><span style="color: blue;">In Model</span></b>
<!-- best programming solution site http://codingcluster.blogspot.in/ --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MoviePersonModel</span>
{
<span style="color: blue;">public</span> MvcContrib.Pagination.<span style="color: #3d85c6;">IPagination</span><<span style="color: #3d85c6;">MvcContrib</span>.Samples.UI.Models.Person> <span style="color: #3d85c6;">Person</span>{ <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> MvcContrib.Pagination.<span style="color: #0b5394;">IPagination</span><<span style="color: #3d85c6;">MvcContrib</span>.Samples.UI.Models.Movie> <span style="color: #3d85c6;">Movie</span>{ <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
}
</pre>
</div>
<br />
initialize the class and apply to view.<br />
<br />
<b><span style="color: blue;">In View</span></b><br />
@model urNamespace.<span style="color: #3d85c6;">MoviePersonModel</span><br />
<br />
<span style="color: #38761d;">//and access its properties: @Model.PersonModel</span><br />
<span style="color: #38761d;"><br /></span>
<span style="background-color: white; color: #cc0000; font-family: trebuchet, arial, verdana, sans-serif; font-size: 12px;">Please share this post with your friends. If it's useful to you. Thanks!.</span></div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-72095777042658530452012-10-02T01:29:00.000+05:302012-10-02T01:30:23.503+05:30ASP.NET MVC: Action Names & NonAction method (ambiguous between error the action methods)<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/10/aspnet-mvc-action-names-nonaction.html" target="_blank">MVC Case Sensitivity & Action Names & NonAction Attribute</a></b><br />
In MVC URLs not being case sensitive. For example if you have the request “Home/About” this goes to HomeController and About action, as well as hOmE/AbOUT is going to the same controller and same action method.<br />
<br />
Suppose if you have two about action methods in the same controller with different cases such as:<br />
<!-- www.bing.com --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">HomeController</span>:Controller{
<span style="color: blue;">public</span> <span style="color: #3d85c6;">ViewResult </span>About() {
<span style="color: blue;">return</span> View();
}
<span style="color: blue;">public</span> <span style="color: #3d85c6;">ViewResult </span>aBOut()
{
<span style="color: blue;">return</span> View();
}
}
</pre>
</div>
<div>
<pre style="line-height: 125%; margin: 0;"></pre>
You will get "ambiguous between the action methods ".<br />
when I call action method About using following url http://your applicationname/Index/ABOUT I got this server error<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ZID5N1vFg6c/UGn0Z6li4EI/AAAAAAAAASc/6Ia0gXwQA78/s1600/mvc+Action+Names+&+Non+Action+method.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="http://1.bp.blogspot.com/-ZID5N1vFg6c/UGn0Z6li4EI/AAAAAAAAASc/6Ia0gXwQA78/s320/mvc+Action+Names+&+Non+Action+method.png" width="320" /></a></div>
<br />
<br />
This means, The framework doesn't determine which "about" function to call, and throws the exception telling that the call is ambiguous. To fix this problem is to change the action name. If for some reason you don’t want to change the action name, and one of these function is not an action, then you can decorate this non action method with NonAction attribute. </div>
<div>
<b><span style="color: blue;"><br /></span></b></div>
<div>
<b><span style="color: blue;">Example:</span></b></div>
<div>
<!-- www.bing.com --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: #3d85c6;">[NonAction]</span>
<span style="color: blue;">public</span> <span style="color: #3d85c6;">ActionResult </span>aBOut()
{
<span style="color: blue;">return</span> View();
}
</pre>
</div>
</div>
<span style="color: #cc0000;">Please share this post with your friends. If it's useful to you. Thanks!.
</span></div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com1tag:blogger.com,1999:blog-630647630228661256.post-3589740765974566022012-10-02T01:01:00.002+05:302012-10-02T01:04:51.898+05:30ASP.NET MVC 4: Error during serialization or deserialization using the JSON / Changing maxJsonLength property in web.config <div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/10/aspnet-mvc-4-error-during-serialization.html" target="_blank">JSON serialization error [maxJsonLength property.]</a></b><br />
In my previous project I need to retrieve ticket from Web service.When I request the web service it return a ticket as JSON format.Some time I need to retrieve more than 10 lacks ticket per requet.In that time I got the following error.<br />
<div>
<br />
<b><span style="color: blue;">Error:</span></b><br />
<div>
<span style="color: red;">Exception information:<br />Exception type: InvalidOperationException<br />Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.</span><br />
<div>
<span style="background-color: #9fc5e8; color: blue;"><br /></span></div>
<div>
<span style="color: blue;"><b>Solution:</b></span></div>
<div>
To solve this issue We need to set Maximum allowed length of json response in Web.config file </div>
The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).</div>
</div>
<div>
<br /></div>
<div>
You can set the MaxJsonLength property on your web.config like </div>
<!-- www.google.com--><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: #007000;"><</span><span style="color: #cc0000;">configuration</span><span style="color: #007000;">></span>
<span style="color: #007000;"><</span><span style="color: #cc0000;">system</span><span style="color: #f00000;">.</span><span style="color: #cc0000;">web</span><span style="color: #f00000;">.</span><span style="color: #cc0000;">extensions</span><span style="color: #007000;">></span>
<span style="color: #007000;"><</span><span style="color: #cc0000;">scripting</span><span style="color: #007000;">></span>
<span style="color: #007000;"><</span><span style="color: #cc0000;">webServices</span><span style="color: #007000;">></span>
<span style="color: #007000;"><</span><span style="color: #cc0000;">jsonSerialization </span><span style="color: #0000c0;">maxJsonLength=</span><span style="background-color: #fff0f0;">"<span style="color: red;">50000000</span>"</span><span style="color: #007000;">/></span>
<span style="color: #007000;"></</span><span style="color: #cc0000;">webServices</span><span style="color: #007000;">></span>
<span style="color: #007000;"></</span><span style="color: #cc0000;">scripting</span><span style="color: #007000;">></span>
<span style="color: #f00000;"><</span><span style="color: #cc0000;">/system.web.extensions</span>>
<span style="color: #007000;"></</span><span style="color: #cc0000;">configuration</span><span style="color: #007000;">></span>
</pre>
</div>
Please share this post with your friends. If it's useful to you. Thanks!.
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-84406194583897954812012-09-30T23:49:00.001+05:302012-10-04T07:47:32.634+05:30How to create a hidden field in asp.net MVC 3<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/09/how-to-create-hidden-field-in-aspnet.html" target="_blank">ASP.NET MVC 3: hidden field in cshtml:</a></b><br />
<div>
<div>
From your model you can creates from your modela hidden input on the form for the field that you pass it.</div>
<div>
<br /></div>
<div>
It is useful for fields in your Model/ViewModel that you need to persist on the page and have passed back when another call is made but shouldn't be seen by the user.</div>
</div>
<div>
<br /></div>
Consider the following ViewModel class:<br />
<div>
<!-- HTML generated using hilite.me --><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ViewModeStudent</span>
{
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> Value { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">int</span> Id { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
}
</pre>
</div>
</div>
<br />
Now you want the edit page to store the ID but have it not be seen: <br />
<div>
<br /></div>
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><% <span style="color: #073763;">using</span>(<span style="color: #3d85c6;">Html.BeginForm</span>() { %>
<%= <span style="color: #3d85c6;">Html.HiddenFor</span>(model.<span style="color: #3d85c6;">Id</span>) %><br />
<%= <span style="color: #3d85c6;">Html.TextBoxFor</span>(model.<span style="color: #3d85c6;">Value</span>) %>
<% } %>
</pre>
</div>
Which results in the equivalent of the following HTML:
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><form name=<span style="color: #a31515;">"form1"</span>>
<input type=<span style="color: #a31515;">"hidden"</span> name=<span style="color: #a31515;">"Id"</span>>2</input>
<input type=<span style="color: #a31515;">"text"</span> name=<span style="color: #a31515;">"Value"</span> <span style="color: blue;">value</span>=<span style="color: #a31515;">"Some Text"</span> />
</form>
</pre>
</div>
Please share this post with your friends. If it's useful to you. Thanks!.
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-78972942172386531132012-09-30T23:24:00.000+05:302012-10-05T00:27:36.454+05:30A circular reference was detected while serializing an object of type 'System.Data.Entity.DynamicProxies in asp.net mvc 4<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/09/a-circular-reference-was-detected-while.html" target="_blank">Handling Circular References ASP.NET MVC 4 Json Serialization - asp.net mvc 4</a></b><br />
In this post I will explain Circular Reference Serialization Error in MVC Entity frame work. In my latest project I need to get data from database for purpose of Autocomplete.So I need data as JSON format.<br />
<br />
When I request the “http://localhost:xxxx/Student/GetStudentJson”<br />
<br />
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-fuC1-1pgH4A/UGiG2GVHBXI/AAAAAAAAASI/PZSxzzvYYQI/s1600/CircularReference_was_detected_codingcluster.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="http://1.bp.blogspot.com/-fuC1-1pgH4A/UGiG2GVHBXI/AAAAAAAAASI/PZSxzzvYYQI/s320/CircularReference_was_detected_codingcluster.jpg" width="320" /></a></div>
</div>
<div>
My http GetStudentJson Method is bellow</div>
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Collections.Generic;
<span style="color: blue;">using</span> System.Data;
<span style="color: blue;">using</span> System.Data.Entity;
<span style="color: blue;">using</span> System.Linq;
<span style="color: blue;">using</span> System.Web;
<span style="color: blue;">using</span> System.Web.Mvc;
<span style="color: blue;">using</span> MvcApplication1.Models;
<span style="color: blue;">namespace</span> MvcApplication1.Controllers
{
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">StudentController</span> : Controller
{
<span style="color: blue;">private</span> SchoolDBContext db = <span style="color: blue;">new</span> SchoolDBContext();
<span style="color: blue;">public</span> JsonResult GetStudentJson()
{
<span style="color: #2b91af;">var</span> students = db.Students .Include(s => s.Standard).Include(s => s.StudentAddress);
<span style="color: blue;">return</span> Json(students, JsonRequestBehavior.AllowGet);
}
<span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> Dispose(<span style="color: #2b91af;">bool</span> disposing)
{
db.Dispose();
<span style="color: blue;">base</span>.Dispose(disposing);
}
}
}
My mode <span style="color: blue;">class</span> <span style="color: #2b91af;">are</span> following
Student.cs
<span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Collections.Generic;
<span style="color: blue;">namespace</span> MvcApplication1.Models
{
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Student</span>
{
<span style="color: blue;">public</span> Student()
{
<span style="color: blue;">this</span>.Courses = <span style="color: blue;">new</span> List<Course>();
}
<span style="color: blue;">public</span> <span style="color: #2b91af;">int</span> StudentID { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> StudentName { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">int</span> StandardId { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: blue;">virtual</span> Standard Standard { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: blue;">virtual</span> StudentAddress StudentAddress { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: blue;">virtual</span> ICollection<Course> Courses { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
}
}
</pre>
</div>
<b><span style="color: blue;">Standard.cs
</span></b><br />
<!-- best programmig solution site codingcluster.blogspot.com--><br />
<div class="source-code">
<pre style="margin: 0px;"><span style="line-height: 125%;"><span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Collections.Generic;
<span style="color: blue;">namespace</span> MvcApplication1.Models
{
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Standard</span>
{
<span style="color: blue;">public</span> Standard()
{
<span style="color: blue;">this</span>.Students = <span style="color: blue;">new</span> List<Student>();
}
<span style="color: blue;">public</span> <span style="color: #2b91af;">int</span> StandardId { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> StandardName { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> Description { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: blue;">virtual</span> ICollection<Student> Students { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
}</span>
</pre>
</div>
<b><span style="color: blue;">StudentAddress.cs</span></b><br />
<!-- best programmig solution site codingcluster.blogspot.com--><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Collections.Generic;
<span style="color: blue;">namespace</span> MvcApplication1.Models
{
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">StudentAddress</span>
{
<span style="color: blue;">public</span> <span style="color: #2b91af;">int</span> StudentID { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> Address1 { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> Address2 { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> City { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: #2b91af;">string</span> State { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: blue;">virtual</span> Student Student { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
}
}
</pre>
</div>
Now I will explain How to solve this problem
In this error occur because the student entity class includes Standard and StudentAddress class entity.
But In GetStudentJson Method tries to convert only Student class object to Json.So that I got the above error.
To solve this error we rewrite the GetStudentJson method
<br />
<br />
<b><span style="color: blue;">Solution One</span></b><br />
<!-- best programmig solution site codingcluster.blogspot.com--><br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: green; font-weight: bold;">public</span> JsonResult <span style="color: #0060b0; font-weight: bold;">GetStudentJson</span>()
{
db.Configuration.ProxyCreationEnabled = <span style="color: green; font-weight: bold;">false</span>;
<span style="color: #303090; font-weight: bold;">var</span> students = db.Students;
<span style="color: green; font-weight: bold;">return</span> <span style="color: #0060b0; font-weight: bold;">Json</span>(students, JsonRequestBehavior.AllowGet);
}
The Out Put <span style="color: green; font-weight: bold;">is</span> Look like bellow
<span style="color: #0000c0;"> [{"StudentID":1,"StudentName":"John","StandardId":1,"Standard":null,</span>
<span style="color: #0000c0;"> "StudentAddress":null,"Courses":[]</span>}]
</pre>
</div>
<br />
<b><span style="color: blue;"><br /></span></b>
<b><span style="color: blue;">Solution Two</span></b><br />
In this type we get selected error<br />
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"> <span style="color: green; font-weight: bold;">public</span> JsonResult <span style="color: #0060b0; font-weight: bold;">GetStudentJson</span>()
{
<span style="color: #303090; font-weight: bold;">var</span> students = <span style="color: green; font-weight: bold;">from</span> s <span style="color: green; font-weight: bold;">in</span> db.Students <span style="color: green; font-weight: bold;">select</span> <span style="color: green; font-weight: bold;">new</span> { s.StudentID, s.StudentName,s.StandardId };
<span style="color: green; font-weight: bold;">return</span> <span style="color: #0060b0; font-weight: bold;">Json</span>(students, JsonRequestBehavior.AllowGet);
}
</pre>
</div>
Please share this post with your friends. If it's useful to you. Thanks!.
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com1tag:blogger.com,1999:blog-630647630228661256.post-22077833393396143712012-09-30T19:07:00.000+05:302012-09-30T19:09:46.734+05:30Difference Between Viewresult() and ActionResult() / different ActionResult types - in asp.net mvc 3<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://codingcluster.blogspot.in/2012/09/difference-between-viewresult-and.html" target="_blank"><b>Types of ASP.NET MVC 3 Action Results: </b></a><br />
<div>
ActionResult is the general base class that all the other results are derived from like ViewResult,JsonResult and so on. ActionResult is an abstract class that can have several subtypes.<br />
Here's a description of different ActionResult types in MVC 3<br />
<br />
<br />
<b>ViewResult</b> - Renders a specifed view to the response stream<br />
<br />
<b>PartialViewResult </b>- Renders a specifed partial view to the response stream<br />
<br />
<b>EmptyResult</b> - An empty response is returned<br />
<br />
<b>RedirectResult</b> - Performs an HTTP redirection to a specifed URL<br />
<br />
<b>RedirectToRouteResult </b>- Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data<br />
<br />
<b>JsonResult</b> - Serializes a given ViewData object to JSON format<br />
<br />
<b>JavaScriptResult</b> - Returns a piece of JavaScript code that can be executed on the client<br />
<br />
<b>ContentResult </b>- Writes content to the response stream without requiring a view<br />
<br />
<b>FileContentResult </b>- Returns a fle to the client<br />
<br />
<b>FileStreamResult </b>- Returns a fle to the client, which is provided by a Stream<br />
<br />
<b>FilePathResult</b> - Returns a fle to the client<br />
<br />
This way you can return multiple types of results</div>
<div>
<br /></div>
<span style="color: #990000;">Please share this post with your friends. If it's useful to you. Thanks!.</span></div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-47378205681356700342012-09-06T13:42:00.001+05:302012-09-06T13:47:46.039+05:30ASP.NET MVC 4: create dropdownlist from an enum (Enumeration helper)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="mobile-photo">
<b><a href="http://codingcluster.blogspot.in/2012/09/aspnet-mvc-4-create-dropdownlist-from.html" target="_blank">Populate dropdownlist with enum in asp.net mvc 4:</a></b></div>
In one of my previous article I'm explained <a href="http://codingcluster.blogspot.in/2012/08/source-how-to-create-drop-down-list-in.html">how to create a dropdownlist from a controller class</a>. And in this post I'm going to explaine how to create a dropdownlist from an enum.<br />
<br />
First create a helper ennum class with your dropdown items. Here I'm using three options "Daily","Quickly","Weekly".<br />
<!-- Best programming solution site www.codingcluster.blogspot.com -->
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: blue;">using</span> System.Reflection;
<span style="color: blue;">using</span> System.ComponentModel;
<span style="color: blue;">namespace</span> EnumHtmlHelper.Helper
{
<span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">EnumDropDown</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">string</span> GetEnumDescription<TEnum>(TEnum <span style="color: blue;">value</span>)
{
FieldInfo fi = <span style="color: blue;">value</span>.GetType().GetField(<span style="color: blue;">value</span>.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.
GetCustomAttributes(<span style="color: blue;">typeof</span>(DescriptionAttribute), <span style="color: blue;">false</span>);
<span style="color: blue;">if</span> ((attributes != <span style="color: blue;">null</span>) && (attributes.Length > 0))
<span style="color: blue;">return</span> attributes[0].Description;
<span style="color: blue;">else</span>
<span style="color: blue;">return</span> <span style="color: blue;">value</span>.ToString();
}
<span style="color: blue;">public</span> <span style="color: blue;">enum</span> Interval
{
[<span style="color: #3d85c6;">Description</span>(<span style="color: #cc0000;">"Daily"</span>)]
D = 1,
[<span style="color: #0b5394;">Description</span>(<span style="color: #cc0000;">"Quick"</span>)]
Q = 2,
[<span style="color: #0b5394;">Description</span>(<span style="color: #cc0000;">"Weekly"</span>)]
W = 3
}
}
}
</pre>
</div>
<br />
Then add the following code into your (Razor) view to get the dropdown list.<br />
<!-- Best programming solution site www.codingcluster.blogspot.com -->
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><span style="color: #cc0000;"><div </span>class<span style="color: #cc0000;">="ddlSmall"></span></pre>
<pre style="line-height: 125%; margin: 0;"> @{
<span style="color: #2b91af;">var</span> EnumInterval = <span style="color: blue;">from</span> Helper.EnumDropDown.Interval n <span style="color: blue;">in</span> Enum.GetValues(<span style="color: blue;">typeof</span>(Helper.EnumDropDown.Interval))
elect <span style="color: blue;">new</span> SelectListItem
{
Value = n.ToString(),
Text = EnumDropDown.GetEnumDescription(n),
};
}
<span style="color: #cc0000;"></div></span></pre>
</div>
<br />
The output of the above code look like this in page source<br />
<!-- Best programming solution site www.codingcluster.blogspot.com -->
<br />
<div class="source-code">
<pre style="line-height: 125%; margin: 0;"><pre style="line-height: 125%; margin: 0;"><<span style="color: blue;">select</span> id=<span style="color: #a31515;">"Interval"</span> name=<span style="color: #a31515;">"Interval"</span>>
<option <span style="color: blue;">value</span>=<span style="color: #a31515;">"D"</span>>Daily</option>
<option <span style="color: blue;">value</span>=<span style="color: #a31515;">"Q"</span>>Quick</option>
<option <span style="color: blue;">value</span>=<span style="color: #a31515;">"W"</span>>Weekly</option>
</<span style="color: blue;">select</span>>
</pre>
</pre>
</div>
The output of the above code look like this in web page
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-i8lVeszhc48/UEhVVPJeUXI/AAAAAAAAAR0/_105C99-q9U/s1600/Dropdownlist%2Bfrom%2Ban%2Benum%2Bin%2Basp.net%2Bmvc%2B4-716484.PNG" style="margin-left: 1em; margin-right: 1em;"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5784967544689283442" src="http://1.bp.blogspot.com/-i8lVeszhc48/UEhVVPJeUXI/AAAAAAAAAR0/_105C99-q9U/s320/Dropdownlist%2Bfrom%2Ban%2Benum%2Bin%2Basp.net%2Bmvc%2B4-716484.PNG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Please share this post with your friends. If it's useful to you. Thanks!.
</div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0tag:blogger.com,1999:blog-630647630228661256.post-17009194185741945342012-09-05T19:22:00.000+05:302012-09-05T19:22:59.118+05:30ASP.NET - MVC 4: How to debug asp.net mvc 4 source code / application in VS 2010?<div dir="ltr" style="text-align: left;" trbidi="on">
<b><a href="http://codingcluster.blogspot.in/2012/09/aspnet-mvc-4-how-to-debug-aspnet-mvc-4.html" target="_blank">ASP.NET: MVC 4 Debugging applications/Projects in visual studio 2010:</a></b><br />
<br />
Below the steps for debug your asp.net mvc 4 source code using visual studio 2010 ultimate:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-Z8rNVq8dwxY/UEdXV_Nd-EI/AAAAAAAAARc/M_PtaEtaurw/s1600/aspdotnet_mvc4_debugging_application.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-Z8rNVq8dwxY/UEdXV_Nd-EI/AAAAAAAAARc/M_PtaEtaurw/s1600/aspdotnet_mvc4_debugging_application.jpg" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
</div>
<ol style="text-align: left;">
<li>First close all Visual Studio instances. </li>
<li>Ensure that you are a member of the local debuggers group (Control Panel, Administrative Tools, Local Security Policy, Security Settings, Local Poliies, User Rights Assignment, Debug Programs). </li>
<li>Change the following registry key(got start type “regedit” in “Search program and files” and click regeedit It will open “registry edit” window) HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Debugger\DisableAttachSecurityWarning from 0 to 1. </li>
<li>Go to IIS Crate a Virtual directory for your web application </li>
<li>Open the project in VS editor. Right click in the project and click property, it will open the property window </li>
<li>Click on Web,on Server tag select Use Custom web service and enter virtual path of our web application</li>
<li>Open virtual path in Any one Browser</li>
<li>In VS IDE click Debug tag and click Attached to process and select W3wp.exe and click attach button </li>
<li>Then put break point(s) and click start with debugging. </li>
</ol>
<br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/06345361591237231354noreply@blogger.com0