How to save a .GST geoset file using MapInfo

It is possible to save a map in .gst form using the WorkSpacePersistence class.

1. Firstly you will need to create an object of FileStream class.

2. The First argument in the constructor of the FileStream class is the file path i.e path where this file needs to be saved.

3. Second argument is the FileMode, I have used FileMode.Create. There are various other option when using FileStream, refer this link same.

4. Use the save method from the WorkSpacePersistance class, pass the map and stream as arguments.

(Note : myMap is the name of the MapControl I have used in my application)

Dim stream As Stream
stream = New FileStream("D:/vaibhav/mumbai.gst", FileMode.Create)

Dim wsp As New MapInfo.Persistence.WorkSpacePersistence()
wsp.Save(myMap.Map, stream)

Format Date Time using BoundColumn / ButtonColumn in DataGrid

A very common desire is to set a column of a DataGrid/GridView to display just the month, day and year (or other custom formats) for a dateTime field.

Below is an example for the same,

The first column with header 'DateTime 1' is a BoundColumn which uses DataFormatString="{0:yyyy.MM.dd}". This will format a date time string of 28-10-2011 12:52:00 to 2011.10.28.

The same can be used with ButtonColumn, as shown here the date time string of 28-10-2011 12:52:00 is converted to a format of 2011.10.28 12:52

<asp:DataGrid ID="abc" CssClass="default" DataKeyField="Id"  
OnItemCommand="myCommand" AutoGenerateColumns="false" Runat="Server" > 

<Columns> 

<asp:BoundColumn HeaderText="DateTime 1" DataField="dt1"  
DataFormatString="{0:yyyy.MM.dd}"  /> 

<asp:ButtonColumn HeaderText="DateTime 2" 
 DataTextField="dt2" DataTextFormatString="{0:yyyy.MM.dd hh:mm}"  
ButtonType="LinkButton" CommandName="Select" runat="server"/> 

</Columns> 

</asp:DataGrid>

How to show image from binary data in database in MVC3 razor?

In this tutorial i will explain that how can we show image in web page from binary data of database.

Get image from database in your controller....
        public ActionResult GetImage(int id)
         {
            var imageData = ....get image from database in binary formate...
            return File( imageData, "image/jpg" );
         }
                Create the action in your controller which will get the binary data of the image from database in the variable.
                Return the File to the view with binary data & image file type.


Call the action from the view
<img src="@Url.Action("GetImage""ImageLoader"
new { id = @Model.Id })" name="logoFile"/>

                Now we need to call the action from the view. Which can be done as shown above.
Where :
GetImage : Action Name. (here put your action name)
ImageLoader : Controller Name. (here put your controller name)
@Model.Id : id of the data for which you want to show the image (here put id for which you want to show the image )


razor examples & work sheet for asp.net MVC

HtmlHelper
Method
Action
Output
@Html.ActionLink(s:text, s:action, o:attributes)
Writes an anchor tag to a link for a specific action.
<a href="action">text</a>
@Html.AntiForgeryToken(s:salt, s:domain, s:path)
Generates a hidden form field (anti-forgery token) that is validated when the form is submitted.

@Html.AttributeEncode(s: input)
HTML-encodes the string (as an attribute).

@Html.BeginForm(s:action, s:controller, o:values)
Writes an opening <form> tag to the response.
<form action="/controller/action/">
@Html.BeginRouteForm(s:routeName)
Writes an opening <form> tag for the route.
<form action="route">
@Html.CheckBox(s:name, b:checked)
Returns a check box input element.
<input type="checkbox" name="name" id="name" checked="checked" />
@Html.CheckBoxFor(e:expression)
Returns a check box input element for the model.
<input type="checkbox" name="name" id="name" checked="checked" />
@Html.DropDownList(s:name, list:selectlistitems)
Returns a single-selection select element.
<select name="name" id="name"></select>
@Html.DropDownListFor(e:expression, list:selectlistitems)
Returns a single-selection select element for the model.
<select name="name" id="name"></select>
@Html.Encode(s:input)
HTML-encodes the string.

@Html.EndForm()
Renders the closing </form> tag to the response.
</form>
@Html.Hidden(s:name, o:value)
Returns a hidden input element.
<input type="hidden" value="value" name="name" />
@Html.HiddenFor(e:expression)
Returns a hidden input element for the model.
<input type="hidden" value="value" name="name" />
@Html.ListBox(s:name, list:selectlistitems)
Returns a multi-select select element.
<select multiple="multiple" name="name" id="name"></select>
@Html.ListBoxFor(e:expression, list:selectlistitems)
Returns a multi-select select element for the model.
<select multiple="multiple" name="name" id="name"></select>
@Html.Password(s:name, o:value)
Returns a password input element.
<input type="password" value="value" name="name" />
@Html.PasswordFor(e:expression)
Returns a password input element for the model.
<input type="password" value="value" name="name" />
@Html.RadioButton(s:name, o:value, b:checked)
Returns a radio button input element.
<input type="radio" value="value" name="name" checked="checked" />
@Html.RadioButtonFor(e:expression, o:value)
Returns a radio button input element for the model.
<input type="radio" value="value" name="name" checked="checked" />
@Html.Partial(s:name, o:model)
Renders a partial view (.cshtml).

@Html.RouteLink(s:text, s:routeName)
Returns an anchor element (a element) that contains the virtual path of the specified action.
<a href="action">text</a>
@Html.TextArea(s:name, s:value)
Returns the specified textarea element.
<textarea name="name">value</textarea>
@Html.TextAreaFor(e:expression)
Returns the specified textarea element for the model.
<textarea name="name">value</textarea>
@Html.TextBox(s:name, o:value)
Returns a text input element.
<input type="text" name="name" value="value" />
@Html.TextBoxFor(e:expression)
Returns a text input element for the model.
<input type="text" name="name" value="value" />
@Html.TextBoxFor(e:expression)
Returns a text input element for the model.
<input type="text" name="name" value="value" />


UrlHelper
Method
Action
Output
@Html.Action(s:action, s:controller)
Generates a fully qualified URL to an action method.

@Html.Content(s:path)
Converts a virtual (relative) path to an application absolute path.

@Html.Encode(s:url)
Encodes special characters in a URL string into character-entity equivalents.

@Html.RouteUrl(s:route)
Generates a fully qualified URL for the specified route name.