Thursday, December 22, 2011

Textmode Password set but not loaded

when setting text in the asp:textbox from serverside its not loaded. the workaround is to set like this:

txtPassword.Attributes("value", p@ssword )

umbraco in godaddy securityexcepion and xslt parsing

set requirePermission=" for clientDependency, Examine and ExamineLuceneIndexSets in webconfig. Then delete all the SQLCE files from bin. Delete the sdf in app_data if there is. then you are god to go.



Wednesday, November 30, 2011

The data area passed to a system call is too small

I saw this error in Vb .Net. Its actually passing lots data in the query string like viewstate values. The problem was I defined the webpage form with method to get but it should post. It was confusing because I worked locally but on the server I was getting this error.

Thursday, October 27, 2011

Add Mimetype to IISExpress

  1. Open a windows command prompt
  2. Switch to the directory that IIS Express is installed in (on my 64 bit Windows 7 system, it was installed in C:\Program Files (x86)\IIS Express)
  3. Execute the following command:
appcmd set config /section:staticContent /+[fileExtension='.less',mimeType='text/css']

Thursday, August 4, 2011

DataMember and Virtual Property problem in WCF

Properties dont come along on the serverside when a property is virtual which is required by different ORMs like EF4 and all. So I need to do this to alternate that:

public class CGContext : DbContext{
        public CGContext() {
            this.Configuration.ProxyCreationEnabled = false;
        }

Friday, July 29, 2011

Cannot insert explicit value for identity column in table ‘x' when IDENTITY_INSERT is set to OFF

Almost all the solution suggests to modify the Id column for that error to set IsDbGenerated=true. But I have some other problems. I have to delete my dbml and therefore regenerate to solve this. Another big bug of linq.

Thursday, July 28, 2011

Model binding insquential lists

<% using (Html.BeginCollectionItem("datesCollection"))
   {%>

The above statement helped me a lot when it came to dynamic population of insequential list in the page. And ofcourse the famous jquery event "live" to bind events to the listitems.






Tuesday, July 12, 2011

ASP .Net MVC, Linq, AutoComplete

Lots of things today. Lots of bugs. We all know this:

public JsonResult GetHotelsByPartialName(string hotelname) {
            var hotelList = AccommodationService.GetAccommodationByPartialname(hotelname);
            return Json(hotelList);
}

But we need to use a simple viewmodel object call JsonHotel here, cause asp .net mvc is not passing the jsonresult for linq classes without even giving an error probably because of lots of properties :

var accommodations = (from o in adc.Accommodations
                                  where o.HotelName.Contains(hotelname)
                                  select new JsonHotel { HotelID = o.HotelID, HotelName = o.HotelName, Region = o.Region }).ToList();

 In the end the below function is very significant: You can see in that the url being used like url: "/Home/GetHotelsByPartialName?hotelname=" + text instead of json style thats cause that probably wont work but webmethods. Removing all row from the table except of first: $('table').find("tr:gt(0)").remove(). This function was used for a autocomplete textbox to filter on table.
          
        function GetData(text) {
            $.ajax({
                url: "/Home/GetHotelsByPartialName?hotelname=" + text,
                type: "POST",
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    $('table').find("tr:gt(0)").remove();
                    $.map(data, function (item) {
                        $('table').append(
                                    '<tr><td><a href="/Home/Accommodation/' + item.HotelID + '">Edit</a>' +
                                        '</td><td>' + item.HotelName +
                                        '</td><td>' + item.Region +
                                        '</td></tr>');
                    });
               },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });

Monday, July 11, 2011

Can't connect to local MySQL server through socket /var/lib/mysql/mysql.sock

sudo chown -R mysql /var/lib/mysql/
sudo chgrp daemon /var/lib/mysql/
sudo /etc/init.d/mysql stopsudo /etc/init.d/mysql start

thats it to your solution to the problem.

Saturday, July 9, 2011

File Uploads of ASP .NET MVC saving image in database

[HttpPost]
        public ActionResult PartialPhotoDetail(int hotelID, HttpPostedFileBase hotelPhoto) {

            if (hotelPhoto.ContentLength > 0) {
                byte[] fileBytes = new byte[hotelPhoto.ContentLength];
                int byteCount = hotelPhoto.InputStream.Read(fileBytes, 0, hotelPhoto.ContentLength);

                AccommodationService.InsertHotelPhoto(new Photo { HotelID = hotelID, photo = fileBytes });
            }

            return RedirectToAction("Accommodation", new { id = hotelID, tab = 4 });
        }

public ActionResult GetHotelPhoto(int id) {
            var hotelPhoto = AccommodationService.GetHotelPhotoById(id);
            return new FileContentResult(hotelPhoto.photo.ToArray(), "image/png");
        }

Thursday, July 7, 2011

Using Jquery dialog on confirmation

$("a[name='delete']").click(function(e){
                e.preventDefault();
                var href = $(this).attr("href");

                $( "#dialog-confirm" ).dialog({
                buttons: {
                        "Delete": function() {
                            window.location.href = href;
                        },
                        Cancel: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });

                $( "#dialog-confirm" ).dialog( "open" );
            });

Monday, July 4, 2011

ASP .Net MVC DropDownList selected value confusion

I just spent an hour around this silly problem. Well its confusing enough from the doc and I should probably blog here so that noone gets into it spending hours.

 <%= Html.DropDownListFor(h => h.HotelMarket.ID, new SelectList(Model.Markets, "Market", "Market", Model.HotelMarket))%>

here you should remember that  h.HotelMarket.ID is the property to be binded to and Model.HotelMarket is the object that this property belongs. Simple but confusing...




Sunday, July 3, 2011

Linq to SQL not generating Associating Property

Its a common problem but it requires a simple solution. Just add or update a column of each table in a relation to be primary key. Then save and you would see associating property.