<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tajuddin&#039;s Blog &raquo; Tajuddin&#039;s Blog</title>
	<atom:link href="http://saradesh.com/tajuddin/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://saradesh.com/tajuddin</link>
	<description>My little world of sharing</description>
	<lastBuildDate>Wed, 07 Mar 2012 05:38:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Comparing span text in jquery and asp.net</title>
		<link>http://saradesh.com/tajuddin/index.php/comparing-span-text-in-jquery-and-asp-net/</link>
		<comments>http://saradesh.com/tajuddin/index.php/comparing-span-text-in-jquery-and-asp-net/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 05:25:11 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[enable]]></category>
		<category><![CDATA[formview]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[span]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=187</guid>
		<description><![CDATA[This post has 424 words. It will take approximately 4 minutes, 14 secondes for reading it.Recently in one of my web application I wanted to disable a button depending on the value in html span. Basically my idea is to enable and disable publish button in my web application depending on span text value. &#160; &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/comparing-span-text-in-jquery-and-asp-net/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 458 words. It will take approximately 4 minutes, 34 secondes for reading it.</p><p>Recently in one of my web application I wanted to disable a button depending on the value in html span. Basically my idea is to enable and disable publish button in my web application depending on span text value.</p>
<p>&nbsp;</p>
<p>In this asp.net web application, user update information as required then click on apply change button. Apply change button update the record in MS Sql server database also change the publish flag to <strong>No</strong>. Now user will be able to see a publish button, this button event basically publish data in external source. When user click on publish data button this will push the data into external server and update the record matching with the primary key. It will also update the local database record only changed the flag to <strong>Yes</strong> so that user would not able to publish this record again unless they do any other changes.</p>
<p>&nbsp;</p>
<p>Here is the html code for span text -</p>
<pre class="brush:php">&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Sync Status: &lt;/th&gt;&lt;td colspan="3"&gt;&lt;asp:Label ID="lblSync" runat="server" Text='&lt;%# Eval("SYNC") %&gt;' /&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan="3"&gt;&lt;asp:Button ID="btnPublish"
        runat="server" Text="Publish to RecData" OnClick="btnPublish_Click" /&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</pre>
<div class="important_block message-block"><p class="printonly"><strong>Important!</strong></p><p class="poststats" class="first-p">This post has 32 words. It will take approximately 19 secondes for reading it.</p><p>I have stripped out all the other html code just to focus on this example. You notice I am using asp label control here which renders as span field in html source.</p>
</div>
<p>&nbsp;</p>
<p>The above label rendered the page with span tag and text of the label text value.</p>
<pre class="brush:php">&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Sync Status: &lt;/th&gt;&lt;td colspan="3"&gt;&lt;span id="MainContent_FormView1_lblSync"&gt;Yes       &lt;/span&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan="3"&gt;&lt;input type="submit" name="ctl00$MainContent$FormView1$btnPublish" value="Publish to RecData" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&amp;quot;ctl00$MainContent$FormView1$btnPublish&amp;quot;, &amp;quot;&amp;quot;, true, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, false, false))" id="MainContent_FormView1_btnPublish" /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</pre>
<p>Here is my jQuery script to grab the span value and set the button property.</p>
<pre class="brush:javascript">&lt;script type="text/javascript"&gt;
        $(function () {

            $("#tabs").tabs();

            var sync = $("#MainContent_FormView1_lblSync").text();

            if ($.trim(sync) != "No") {
                alert(sync);
                $("#MainContent_FormView1_btnPublish").attr("disabled", "disabled");
            }

        });
    &lt;/script&gt;</pre>
<p>Now when the span text is Yes the button get disabled and for anything else it is enabled.</p>
<p>This is the working screen shot -</p>
<p><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/03/button_enable.jpg"><img class="alignnone size-full wp-image-188" title="button_enable" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/03/button_enable.jpg" alt="" width="810" height="735" /></a></p>
<p>&nbsp;</p>
<p><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/03/button_disabled.jpg"><img class="alignnone size-full wp-image-189" title="button_disabled" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/03/button_disabled.jpg" alt="" width="816" height="720" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/comparing-span-text-in-jquery-and-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Databind in checkbox list in ASP.NET</title>
		<link>http://saradesh.com/tajuddin/index.php/databind-in-checkbox-list-in-asp-net/</link>
		<comments>http://saradesh.com/tajuddin/index.php/databind-in-checkbox-list-in-asp-net/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 03:20:24 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[APEX]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[checkboxlist]]></category>
		<category><![CDATA[databind]]></category>
		<category><![CDATA[dynamic databind]]></category>
		<category><![CDATA[formview]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[sqldatasource]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=183</guid>
		<description><![CDATA[This post has 2035 words. It will take approximately 20 minutes, 21 secondes for reading it.Checkbox list does not support multiple databind. To be a bit clearer, it does not support databind for multi select in checkbox list. It only stores one entry from the checkbox list. In one of my recent project I had &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/databind-in-checkbox-list-in-asp-net/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 2076 words. It will take approximately 20 minutes, 45 secondes for reading it.</p><p>Checkbox list does not support multiple databind. To be a bit clearer, it does not support databind for multi select in checkbox list. It only stores one entry from the checkbox list.</p>
<p>In one of my recent project I had to implement checkbox list where user can tick multiple checkboxes and store them into the database table. In this project I was using SQL server express database and storing the data using the data in colon (:) delimited value so that I can push the data back into Oracle database to use this in Oracle APEX application. You can store your data whatever fashion you want to save in. In oracle APEX application it is an in build feature where you can bind data dynamically in checkbox list. Unfortunately you can not do this in ASP.NET.</p>
<p>Lets start the task, I have used SqlDataSource for database operation in this example and connection string pulled from web.config file. Here is my SqlDataSource structure -</p>
<pre class="brush:php">&lt;asp:SqlDataSource ID="dsImported" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ApplicationServices %&gt;"
        SelectCommand="SELECT * FROM [rtt_sites] where sit_id=@sit_id" UpdateCommand="update rtt_sites set name=@name, sit_type=@sit_type, status=@status, primary_function=@primary_function, fee_type=@fee_type, access_type=@access_type, update_date=getdate() where sit_id=@sit_id"&gt;
        &lt;UpdateParameters&gt;
            &lt;asp:Parameter Name="sit_id" Type="Decimal" /&gt;
            &lt;asp:Parameter Name="name" Type="String" /&gt;
            &lt;asp:Parameter Name="status" Type="String" /&gt;
            &lt;asp:Parameter Name="primary_function" Type="String" /&gt;
        &lt;/UpdateParameters&gt;
        &lt;SelectParameters&gt;
            &lt;asp:QueryStringParameter QueryStringField="sit" Name="sit_id" Type="Int32" /&gt;
        &lt;/SelectParameters&gt;
    &lt;/asp:SqlDataSource&gt;</pre>
<p>In the above sqldatasource I am actually using a query string to fetch data in a Formview. User can update or change record if they want to. Now here is my formview structure -</p>
<pre class="brush:php">&lt;asp:FormView ID="FormView1" runat="server" AllowPaging="True"
        DataKeyNames="recId" DataSourceID="dsImported" DefaultMode="Edit"
        Width="100%"&gt;
        &lt;EditItemTemplate&gt;

        &lt;table cellpadding="3" cellspacing="3" &gt;
        &lt;tr&gt;&lt;th&gt;Record Id:&lt;/th&gt;&lt;td&gt;&lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Eval("recId") %&gt;' /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Site Id:&lt;/th&gt;&lt;td&gt;&lt;asp:TextBox ID="sit_idTextBox" runat="server" Text='&lt;%# Bind("sit_id") %&gt;' ReadOnly="true" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Site Name:&lt;/th&gt;&lt;td&gt;&lt;asp:TextBox ID="nameTextBox" runat="server" Text='&lt;%# Bind("name") %&gt;' ReadOnly="true" Width="400" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Site Type: &lt;/th&gt;&lt;td&gt;
    &lt;asp:CheckBoxList ID="chkSiteType" runat="server" RepeatColumns="5" DataSourceID="dsSiteType"
        DataTextField="description" DataValueField="returnVal"&gt;
    &lt;/asp:CheckBoxList&gt;

        &lt;tr&gt;&lt;th&gt;Status:&lt;/th&gt;&lt;td&gt;
            &lt;asp:DropDownList ID="dlStatus" runat="server" selectedValue='&lt;%# Bind("status") %&gt;' &gt;
            &lt;asp:ListItem  Text="Select status" Value="" /&gt;
            &lt;asp:ListItem Text="Current" Value="CURRENT" /&gt;
            &lt;asp:ListItem Text="Closed" Value="CLOSED" /&gt;

            &lt;/asp:DropDownList&gt;
        &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Primary function:&lt;/th&gt;&lt;td&gt;
    &lt;asp:DropDownList ID="dlPrimaryFunction" runat="server"
        selectedValue='&lt;%# Bind("primary_function") %&gt;' DataSourceID="dsSiteType"
        DataTextField="description" DataValueField="returnVal" AppendDataBoundItems="true" &gt;
    &lt;asp:ListItem Value="" Text="Select function" /&gt;

    &lt;/asp:DropDownList&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Longitude: &lt;/th&gt;&lt;td&gt;&lt;asp:TextBox ID="txtLongitude" runat="server" Text='&lt;%# Bind("longitude") %&gt;' Width="200" /&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th&gt;Latitude: &lt;/th&gt;&lt;td&gt;&lt;asp:TextBox ID="txtLatitude" runat="server" Text='&lt;%# Bind("latitude") %&gt;' Width="200" /&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th&gt;Fee Type:&lt;/th&gt;&lt;td&gt;
            &lt;asp:CheckBoxList ID="chkFeeType" runat="server" RepeatColumns="6"&gt;
                &lt;asp:ListItem Value="ANOFEES"&gt;No Fees&lt;/asp:ListItem&gt;
                &lt;asp:ListItem Value="BOAT"&gt;Boat Tour&lt;/asp:ListItem&gt;
                &lt;asp:ListItem Value="PARK"&gt;Park Entry&lt;/asp:ListItem&gt;
                &lt;asp:ListItem Value="CAMPING"&gt;Camping&lt;/asp:ListItem&gt;
                &lt;asp:ListItem Value="CAVING"&gt;Caving&lt;/asp:ListItem&gt;
                &lt;asp:ListItem Value="SITE"&gt;Site Entry&lt;/asp:ListItem&gt;

            &lt;/asp:CheckBoxList&gt;
        &lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th&gt;Access Type: &lt;/th&gt;&lt;td&gt;&lt;asp:CheckBoxList ID="chkAccessType" runat="server"
                RepeatColumns="7"&gt;
            &lt;asp:ListItem Value="BICYCLE"&gt;Bicycle&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="BUS"&gt;Bus&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="CANOE"&gt;Canoe&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="CAR"&gt;Car&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="CARAVAN"&gt;Caravan&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="AIRCRAFT"&gt;Fixed Wing Aircraft&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="FOOT"&gt;Foot&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="4WD"&gt;Four Wheel Drive&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="HELICOPTER"&gt;Helicopter&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="HORSE"&gt;Horse&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="PWR_BOAT"&gt;Power Boat&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="SAIL_BOAT"&gt;Sail Boat&lt;/asp:ListItem&gt;
            &lt;asp:ListItem Value="Bike"&gt;Trail Bike&lt;/asp:ListItem&gt;
            &lt;/asp:CheckBoxList&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Created on: &lt;/th&gt;&lt;td&gt;&lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("create_date") %&gt;'  ReadOnly="true"  /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Last updated: &lt;/th&gt;&lt;td&gt;&lt;asp:TextBox ID="TextBox2" runat="server" Text='&lt;%# Bind("update_date") %&gt;' ReadOnly="true" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Created on: &lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Created on: &lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Created on: &lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;/table&gt;
            &lt;asp:Label ID="lblFeetype" runat="server" Text='&lt;%# Eval("fee_type") %&gt;' Visible="false" /&gt; &lt;br /&gt;
            &lt;asp:Label ID="lblAccessType" runat="server" Text='&lt;%# Eval("access_type") %&gt;' Visible="false" /&gt; &lt;br /&gt;
           &lt;asp:Label ID="lblSiteType" runat="server" Text='&lt;%# Eval("sit_type") %&gt;' Visible="false" /&gt;
            &lt;asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
                CommandName="Update" Text="Update" /&gt;
            &amp;nbsp;&lt;asp:LinkButton ID="UpdateCancelButton" runat="server"
                CausesValidation="False" PostBackUrl="~/importSite.aspx" Text="Cancel" /&gt;

                &lt;asp:SqlDataSource ID="dsSiteType" runat="server"
        ConnectionString="&lt;%$ ConnectionStrings:ApplicationServices %&gt;"
        SelectCommand="SELECT [description], [returnVal] FROM [rtt_param] WHERE ([CODE] = @CODE)"&gt;
        &lt;SelectParameters&gt;
            &lt;asp:Parameter DefaultValue="SITE_TYPE" Name="CODE" Type="String" /&gt;
        &lt;/SelectParameters&gt;
    &lt;/asp:SqlDataSource&gt;
        &lt;/EditItemTemplate&gt;

    &lt;/asp:FormView&gt;
    &lt;asp:Label ID="lblMsg" runat="server" &gt;&lt;/asp:Label&gt;
&lt;br /&gt;</pre>
<p>Now in the above formview I also have couple of dynamic dropdown list populated from database table. Hope it is easy to understand. If you look at the above code closely, you will notice I have binded data in all textbox and dropdown list controls however I did not bind data in checkbox list control at this stage.</p>
<p><span id="more-183"></span></p>
<p>Lets start first bind the data dynamically in those checkboxes. So I want to bind data on formview databound event. To retrieve the value from database for these checkboxes I have created a few labels to fetch the data. I also have set the visible property to false so that they are not visible to user.</p>
<p>Now the aim is to grab the value from these label controls and split them into arrays then fetch the data into checkbox list control <img src='http://saradesh.com/tajuddin/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>In VB -</p>
<pre class="brush:vb">Protected Sub FormView1_DataBound(sender As Object, e As System.EventArgs) Handles FormView1.DataBound
        'access the checkbox list control in Formview
        Dim c As CheckBoxList = CType(FormView1.FindControl("chkFeeType"), CheckBoxList)
         'access the Label control in Formview
        Dim feeType As Label = CType(FormView1.FindControl("lblFeetype"), Label)
        'get the value of label field
        Dim rawVal As String = feeType.Text

        'create an array using split
        Dim str As String() = rawVal.Split(":"c)

        'loop through the array and bind to checkbox list
        For i As Integer = 0 To c.Items.Count - 1
            If str.Contains(c.Items(i).Value) Then
                c.Items(i).Selected = True
            End If
        Next

    End Sub</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>In C# -</p>
<pre class="brush:csharp">FormView1_DataBound(object sender, System.EventArgs e)
{
	//access the checkbox list control in Formview
	CheckBoxList c = (CheckBoxList)FormView1.FindControl("chkFeeType");
	//access the Label control in Formview
	Label feeType = (Label)FormView1.FindControl("lblFeetype");
	//get the value of label field
	string rawVal = feeType.Text;

	//create an array using split
	string[] str = rawVal.Split(':');

	//loop through the array and bind to checkbox list
	for (int i = 0; i &lt;= c.Items.Count - 1; i++) {
		if (str.Contains(c.Items(i).Value)) {
			c.Items(i).Selected = true;
		}
	}

}</pre>
<p>&nbsp;</p>
<div class="warning_block message-block"><p class="printonly"><strong>Warning!</strong></p><p class="poststats" class="first-p">This post has 30 words. It will take approximately 18 secondes for reading it.</p><p>I have omitted some codes here, just wanted to show one example how to fetch checkbox list dynamically. Follow the same procedure if you have multiple checkbox list like mine.</p>
</div>
<p>Here is the screen shot when data fetched in checkboxes -</p>
<div id="attachment_184" class="wp-caption alignnone" style="width: 820px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/checkboxlist.jpg"><img class="size-full wp-image-184" title="Data Bind in Checkbox list" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/checkboxlist.jpg" alt="" width="810" height="705" /></a><p class="wp-caption-text">CheckBoxList</p></div>
<p>&nbsp;</p>
<p>You can see in the above screen data are nicely fetched in CheckboxList. Now the question is how can I update the data when user tick or un-tick any of those check boxes. Well to do this I had to create a custom function and event and call that in page load to bind update parameters in sqldatasource.</p>
<p>Lets look at the function first, this function basically grab the value from checkboxlist and combine them together in whatever format I want.</p>
<p>In VB -</p>
<pre class="brush:vb">Private Function GetStringFromCheckBoxList(ByVal chk As CheckBoxList) As String

        Dim strTemp As String = String.Empty

        For Each lst As ListItem In chk.Items
            If lst.Selected Then
                strTemp = strTemp &amp; lst.Value &amp; ":"
            End If
        Next

        Return strTemp.Trim(":")

    End Function</pre>
<p>In C# -</p>
<pre class="brush:csharp">private string GetStringFromCheckBoxList(CheckBoxList chk)
{

	string strTemp = string.Empty;

	foreach (ListItem lst in chk.Items) {
		if (lst.Selected) {
			strTemp = strTemp + lst.Value + ":";
		}
	}

	return strTemp.Trim(":");

}</pre>
<p>The above function basically grabbing the selected value from checkbox list and return as string with colon(:) separated value. Now I got the the string value and I have to update the database column. Here is my code on page load -</p>
<p>In VB -</p>
<pre class="brush:vb">Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        'access the checkbox lists in FormView control
        Dim chkBox As CheckBoxList = CType(FormView1.FindControl("chkFeeType"), CheckBoxList)
        Dim chkAccess As CheckBoxList = CType(FormView1.FindControl("chkAccessType"), CheckBoxList)
        Dim chkSite As CheckBoxList = CType(FormView1.FindControl("chkSiteType"), CheckBoxList)
        If Me.IsPostBack Then

            'collect and format the checkbox list values and set to string variable
            Dim st As String = GetStringFromCheckBoxList(chkBox)
            Dim ac As String = GetStringFromCheckBoxList(chkAccess)
            Dim sit As String = GetStringFromCheckBoxList(chkSite)

            'assign update parameter values here to update database
            dsImported.UpdateParameters.Add("fee_type", st)
            dsImported.UpdateParameters.Add("access_type", ac)
            dsImported.UpdateParameters.Add("sit_type", sit)
        End If

    End Sub</pre>
<p>In C# -</p>
<pre class="brush:csharp">Page_Load(object sender, System.EventArgs e)
{
	//access the checkbox lists in FormView control
	CheckBoxList chkBox = (CheckBoxList)FormView1.FindControl("chkFeeType");
	CheckBoxList chkAccess = (CheckBoxList)FormView1.FindControl("chkAccessType");
	CheckBoxList chkSite = (CheckBoxList)FormView1.FindControl("chkSiteType");

	if (this.IsPostBack) {
		//collect and format the checkbox list values and set to string variable
		string st = GetStringFromCheckBoxList(chkBox);
		string ac = GetStringFromCheckBoxList(chkAccess);
		string sit = GetStringFromCheckBoxList(chkSite);

		//assign update parameter values here to update database
		dsImported.UpdateParameters.Add("fee_type", st);
		dsImported.UpdateParameters.Add("access_type", ac);
		dsImported.UpdateParameters.Add("sit_type", sit);
	}

}</pre>
<p>Now here is your fully functional checkbox list databind in very simple and easy way. Let me know if you have any problem or issue implementing this. Good luck</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/databind-in-checkbox-list-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling webservice in Ajax using jQuery in ASP.NET</title>
		<link>http://saradesh.com/tajuddin/index.php/calling-webservice-in-ajax-using-jquery-in-asp-net/</link>
		<comments>http://saradesh.com/tajuddin/index.php/calling-webservice-in-ajax-using-jquery-in-asp-net/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 08:10:23 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=177</guid>
		<description><![CDATA[This post has 721 words. It will take approximately 7 minutes, 12 secondes for reading it.In this example I have shown how to call a web-service using jQuery AJAX. For instance I wanted to load some addition information or external information in my website using web-service and Ajax call. If you do not know how &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/calling-webservice-in-ajax-using-jquery-in-asp-net/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 731 words. It will take approximately 7 minutes, 18 secondes for reading it.</p><p>In this example I have shown how to call a web-service using jQuery AJAX. For instance I wanted to load some addition information or external information in my website using web-service and Ajax call. If you do not know how to create a web-service then you open your website in Visual Web Developer 2005/2008/2010 right click on the root directory in file browsing (explorer) window and click on <strong>add new item</strong>. Select web-service from the suggested list and name it whatever you like. Usually it places the code file in APP_CODE folder. I have created a simple web-service called myService.asmx, here is my code -</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

/// &lt;summary&gt;
/// Summary description for myService
/// &lt;/summary&gt;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class myService : System.Web.Services.WebService {

    public myService () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }

    [WebMethod]
    public string cityWeather(string city)
    {

        if (city=="Dhaka")
            return "City: " + city + "- Sunny. This is the time to go out and have fun. fsd";
        else
        return
            "City:" + city + "- Cloudy";

    }

}</pre>
<p>The purpose of this web-service to display some information depending on user input in URL query string. Basically the URL will include a city name and web-service will display the weather information for that city. I have tried to make this simple to understand.</p>
<p>Once my web-service is ready, I have called the web service from aspx page using jQuery Ajax. First include the jquery script in the header section of your aspx page. If you don&#8217;t have jquery file then you can download it from <a title="jQuery Website" href="http://www.jquery.com" target="_blank">jQuery</a> website.</p>
<pre class="brush:php">&lt;head&gt;

&lt;script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;AJAX call using jQuery in ASP.NET &lt;/h2&gt;

&lt;/body&gt;</pre>
<p>To grab the query string parameter I had write a javascript function, you might do it in different way. I have used only java to accomplish this functionality.</p>
<pre class="brush:javascript">        // Read a page's GET URL variables and return them as an associative array.
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
            for (var i = 0; i &lt; hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }</pre>
<p>&nbsp;</p>
<p>Here is the code of AJAX call in my aspx page -</p>
<pre class="brush:javascript">var ct=getUrlVars()["name"] ;

        $.ajax({
            url: "services/myService.asmx/cityWeather",
            dataType: "html", // data type can have text
            type: "post",
            data: { city: ct },
            error: function (err) {
                alert("Error: " + err.toString());
            },
            success: function (data) {
                $("#cityWeather").html(data);
            },
            async: false,
            timeout: 2000

        });</pre>
<p>&nbsp;</p>
<p>In the jQuery ajax call, I am calling the <strong>cityWeather</strong> function from myService.asmx page using URL parameter name.</p>
<p>I also have a html div to display or load the content. Here is the div code -</p>
<pre class="brush:php">&lt;div id="cityWeather"&gt;

&lt;/div&gt;</pre>
<p><span id="more-177"></span></p>
<p>Well so far so good and working well. I thought it would be nice to display a loading image when content is loading. Depending on the length of the content and source of the content it might take a few seconds to load. To give better user experience here is what I have done, I have included a loading gif file while content loading.</p>
<p>&nbsp;</p>
<pre class="brush:javascript">&lt;script type="text/javascript"&gt;

    $(document).ready(function () {

        // display temp image while loading the content
        $("#cityWeather").html("&lt;img src='images/al1.gif' /&gt;");

      // get the query string value
        var ct=getUrlVars()["name"] ;

        $.ajax({
            url: "services/myService.asmx/cityWeather",
            dataType: "html", // data type can have text
            type: "post",
            data: { city: ct },
            error: function (err) {
                alert("Error: " + err.toString());
            },
            success: function (data) {
                $("#cityWeather").html(data);
            },
            async: false,
            timeout: 2000

        });

        // Read a page's GET URL variables and return them as an associative array.
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
            for (var i = 0; i &lt; hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }

    });
&lt;/script&gt;</pre>
<p>The sreen looks like this-</p>
<div id="attachment_179" class="wp-caption alignnone" style="width: 667px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/ajax-call.jpg"><img class="size-full wp-image-179" title="ajax call in ASP.NET jQuery" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/ajax-call.jpg" alt="" width="657" height="388" /></a><p class="wp-caption-text">Web-service Call</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/calling-webservice-in-ajax-using-jquery-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fancybox in APEX dynamic report</title>
		<link>http://saradesh.com/tajuddin/index.php/fancybox-in-apex-dynamic-report/</link>
		<comments>http://saradesh.com/tajuddin/index.php/fancybox-in-apex-dynamic-report/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 04:59:23 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[APEX]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[fancy-box]]></category>
		<category><![CDATA[fancybox]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=165</guid>
		<description><![CDATA[This post has 493 words. It will take approximately 4 minutes, 55 secondes for reading it.Using fancybox in Oracle Application Express (APEX) can increase the page load performance specially when You have lot of items in one page and user needs to scroll down to reach the bottom which is quite annoying for some users. &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/fancybox-in-apex-dynamic-report/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 493 words. It will take approximately 4 minutes, 55 secondes for reading it.</p><p>Using fancybox in Oracle Application Express (APEX) can increase the page load performance specially when You have lot of items in one page and user needs to scroll down to reach the bottom which is quite annoying for some users. You can split your long page scrolling content into few pages and use link to open these additional information on demand using fancy box. So you are not leaving the main page but you can still access additional resources if you want to. It is working so good so far for me. Read my previous article if you do not know how to <a title="Implementing fancybox in oracle APEX application" href="http://saradesh.com/tajuddin/index.php/implementing-fancybox-in-oracle-apex-application/">implement fancybox in APEX</a>.</p>
<p>Now when it comes to the point where I wanted to implement fancybox in APEX dynamic report. Basically what I am trying to do in my report is &#8211; provide URL link for relevant image and display the image in fancybox when user click on it.</p>
<p>It works good when I load the page and rendered the report with the following code -</p>
<pre class="brush:javascript">&lt;script type="text/javascript"&gt;

$(document).ready(function(){
          $("a.fancyImg").fancybox({
                                   'transitionIn'	: 200,
                                    'transitionOut'	: 200
                                   });
                          });
&lt;/script&gt;</pre>
<p>The fancybox functionality breaks when partial post back happened into the page. So when I want to do column sorting or perform any other action in dynamic report fancybox link does not work. I understand that because my function only called once on document ready and it does not work for partial page load. Here is the screen capture of my report.</p>
<p><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/fancyBox-in-IR.png"><img class="alignnone size-full wp-image-166" title="fancyBox in IR" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/fancyBox-in-IR.png" alt="" width="1101" height="583" /></a></p>
<p>I have used custom SQL report query for URL link column. Here is the sample if you want to know how -</p>
<pre class="brush:sql">SELECT F.FAC_ID,
       F.FAC_TYPE,
       F.LOCATION,
       F.FAC_ASSET_DESC "Description",
       F.FAC_ASSET_NO "Asset No",
       F.FAC_ASSET_CONDITION "Condition",
       F.FAC_REPLACEMENT_COST "Initial Cost",
       F.REPLACEMENT_COST_TODAY "Todays Cost",
       F.FAC_LATITUDE_DEC "Latitude",
       F.FAC_LONGITUDE_DEC "Longitude",
       CASE
          WHEN fil.fil_id IS NOT NULL
          THEN
                '&lt;a class="fancyImg" href="f?p=&amp;APP_ID.:44:&amp;SESSION.:::44:P44_FIL_ID:'
             ¦¦ fil_id
             ¦¦ '"&gt;View Image&lt;/a&gt;'
          ELSE
             'No image'
       END
          Image
  FROM FACILITIES F, BUILDINGS B, FILES FIL
 WHERE     F.FAC_ID = B.FAC_ID(+)
       AND F.FAC_TYPE = 'BUILDING'
       AND FIL.SOURCE_ID(+) = F.FAC_ID</pre>
<p>Now I have changed my javascript to use without document ready function. Here is the code -</p>
<pre class="brush:javascript">&lt;script type="text/javascript"&gt;

function fancyGallery(){
$("a.fancyImg").fancybox({
   'transitionIn'		: 200,
   'transitionOut'		: 200
});
}
&lt;/script&gt;
</pre>
<p>Call this function in the report dynamically in onClick event.</p>
<pre class="brush:sql">CASE
          WHEN fil.fil_id IS NOT NULL
          THEN
                '&lt;a class="fancyImg" onClick="javascript:fancyGallery();" href="f?p=&amp;APP_ID.:44:&amp;SESSION.:::44:P44_FIL_ID:'
             ¦¦ fil_id
             ¦¦ '"&gt;View Image&lt;/a&gt;'
          ELSE
             'No image'
       END
          Image</pre>
<p>It works fine in IE but I am not sure about FireFox.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/fancybox-in-apex-dynamic-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing fancybox in oracle APEX application</title>
		<link>http://saradesh.com/tajuddin/index.php/implementing-fancybox-in-oracle-apex-application/</link>
		<comments>http://saradesh.com/tajuddin/index.php/implementing-fancybox-in-oracle-apex-application/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 06:13:30 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[APEX]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[fancy]]></category>
		<category><![CDATA[fancybox]]></category>
		<category><![CDATA[glassbox]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lightbox]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=153</guid>
		<description><![CDATA[This post has 781 words. It will take approximately 7 minutes, 48 secondes for reading it.Recently in one of my application I have implemented Fancybox to give better user experience. I guess this is quite useful when you have too many items in one page and user has to scroll down to view details in &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/implementing-fancybox-in-oracle-apex-application/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 851 words. It will take approximately 8 minutes, 30 secondes for reading it.</p><p>Recently in one of my application I have implemented <a title="Fancybox" href="http://fancybox.net" target="_blank">Fancybox </a>to give better user experience. I guess this is quite useful when you have too many items in one page and user has to scroll down to view details in the page. This will give better user experience hiding extra stuff from the page and make it available on demand or request.</p>
<p>I wanted to implement this functionality because in my relational database I have a master table which holds most of the common fields and I have created some child tables for store extra information for different types of assets e.g. furniture, building, structure etc. Instead of sending user to different page to enter additional information, I wanted to give a bit flexibility so that user will be in the same page and they can enter details of specific asset information in fancy popup window if they want to. It will also give a bit better experience in terms of page load as it will load only necessary fields. The page looks like this -</p>
<p><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-12.54.53-PM.png"><img class="alignnone size-full wp-image-144" title="FancyBox screen" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-12.54.53-PM.png" alt="" width="1101" height="629" /></a></p>
<p>First of all, you have to download the script from <a title="fancybox" href="http://fancybox.net" target="_blank">http://fancybox.net </a>and Once you downloaded zip file, extract it where ever the location you like.</p>
<p><span id="more-153"></span></p>
<p>Copy only these three files &#8211; jquery.fancybox-1.3.4.css,  jquery.fancybox-1.3.4.pack.js,  fancybox.png and place into your APEX application image directory. Assuming you already have jQuery js file included in the template if not then include the jQuery js file as well. Here is my APEX image directory, I have used theme folder to store this files and make sure all files in the same location so that css file can find the image for fancybox style.</p>
<div id="attachment_154" class="wp-caption alignnone" style="width: 700px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/i_directory.jpg"><img class="size-full wp-image-154" title="APEX image directory" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/i_directory.jpg" alt="" width="690" height="481" /></a><p class="wp-caption-text">File location</p></div>
<p>Now, edit the page template to include these js and css files. I have used global template to load those files as I want to use them from various pages however you can load or call this files from specific page. Click on the edit page link in the page where you want to implement this functionality.</p>
<div id="attachment_145" class="wp-caption alignnone" style="width: 396px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-12.57.41-PM.png"><img class="size-full wp-image-145" title="Edit page" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-12.57.41-PM.png" alt="" width="386" height="312" /></a><p class="wp-caption-text">Edit page</p></div>
<p>Include the following script in the head section of the template, see the image below.</p>
<pre class="brush:php">&lt;script src="#IMAGE_PREFIX#themes/calm/jquery-1.4.2.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="#IMAGE_PREFIX#themes/calm/jquery.fancybox-1.3.4.pack.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" href="#IMAGE_PREFIX#themes/calm/jquery.fancybox-1.3.4.css" type="text/css" /&gt;</pre>
<p>Here is the screen shot.</p>
<div id="attachment_146" class="wp-caption alignnone" style="width: 797px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-12.58.26-PM.png"><img class="size-full wp-image-146" title="Edit Template" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-12.58.26-PM.png" alt="" width="787" height="407" /></a><p class="wp-caption-text">Main Template</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Once you done with the template, click on apply changes button. Now include the anchor into the page, I wanted to include this in facility details page. I have used dynamic parameters in the link to set the value dynamically.</p>
<p>&amp;APP_ID. &#8211; get the application id</p>
<p>&amp;P3_DEST_PAGE. &#8211; this is the page number that I want to send, get this value from the page item</p>
<p>&amp;SESSION. and &amp;DEBUG. &#8211; include the session and debug in the url</p>
<p>Set <img src='http://saradesh.com/tajuddin/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> 5_AST_ID value with &amp;P3_AST_ID value.</p>
<pre class="brush:php">&lt;a id="assetLink" href="f?p=&amp;APP_ID.:&amp;P3_DEST_PAGE.:&amp;SESSION.::&amp;DEBUG.::P5_AST_ID:&amp;P3_AST_ID."&gt;Building Details&lt;/a&gt;</pre>
<p>Here is the screen shot -</p>
<div id="attachment_148" class="wp-caption alignnone" style="width: 857px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-1.06.06-PM.png"><img class="size-full wp-image-148" title="Anchor code" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-1.06.06-PM.png" alt="" width="847" height="412" /></a><p class="wp-caption-text">Anchor Code</p></div>
<p>Include the following javascript in the header section of this region.</p>
<pre class="brush:javascript">$(document).ready(function () {

$("#assetLink").fancybox({
				'width'			: '60%',
				'height'		: '70%',
				'autoScale'		: true,
				'transitionIn'		: 200,
				'transitionOut'	        : 200,
				'type'			: 'iframe'
			});
 });

&lt;/script&gt;

Here is the screen capture -</pre>
<div id="attachment_142" class="wp-caption alignnone" style="width: 792px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-1.00.21-PM.png"><img class="size-full wp-image-142" title="javascript" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-1.00.21-PM.png" alt="" width="782" height="429" /></a><p class="wp-caption-text">JavaScript</p></div>
<p>Well, now it is time for testing. Click on apply changes and see if the fancybox pop-up. So far so good. Now this anchor link does not looking so good for me, I want to give it like a button style look and feel. I have wrote the style for this anchor and placed this into the head section. Here is the style code -</p>
<p>&nbsp;</p>
<pre class="brush:css">&lt;style type="text/css"&gt;
a#assetLink{
border: 1px solid gray;
text-decoration:none;
display:block;
line-height:14px;
padding: 3px;
width:120px;
text-align:center;
float:right;
background-color:#E1842A;
color:#fff
}
a#assetLink:hover
{
color:#000
}

&lt;/style&gt;</pre>
<p>The screen capture -</p>
<div id="attachment_143" class="wp-caption alignnone" style="width: 833px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-1.02.23-PM.png"><img class="size-full wp-image-143" title="Style code" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/Screen-shot-2012-02-01-at-1.02.23-PM.png" alt="" width="823" height="573" /></a><p class="wp-caption-text">CSS CODE</p></div>
<p class="brush:javascript">This is looking better now, here is the screen looks like -</p>
<div id="attachment_155" class="wp-caption alignnone" style="width: 770px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/i_directory1.jpg"><img class="size-full wp-image-155" title="APEX Page" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/02/i_directory1.jpg" alt="" width="760" height="525" /></a><p class="wp-caption-text">Page with link</p></div>
<p class="brush:javascript">Now, I can see it is all working good but I do not want to display the link when entering new record. So I have to write some javascript to do this -</p>
<pre class="brush:javascript">// get the value of the primary key
var dl = $('#P3_FAC_ID').val();
if (dl.length===0)
{
      $('#assetLink').hide();
}</pre>
<p>Get the value of the primary key in the page and set the visibility of the link accordingly.</p>
<p>Let me know if you have any problem with instruction and implement.</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/implementing-fancybox-in-oracle-apex-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Hide checkbox group in APEX using jQuery</title>
		<link>http://saradesh.com/tajuddin/index.php/hide-checkbox-group-in-apex-using-jquery/</link>
		<comments>http://saradesh.com/tajuddin/index.php/hide-checkbox-group-in-apex-using-jquery/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 06:46:33 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[APEX]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[show]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=132</guid>
		<description><![CDATA[This post has 577 words. It will take approximately 5 minutes, 46 secondes for reading it.In Oracle APEX I wanted to show and hide a check box group depending on the value of another text-field. I guess it is quite handy when you want to hide irrelevant fields from the page and when you have &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/hide-checkbox-group-in-apex-using-jquery/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 611 words. It will take approximately 6 minutes, 6 secondes for reading it.</p><p>In Oracle APEX I wanted to show and hide a check box group depending on the value of another text-field. I guess it is quite handy when you want to hide irrelevant fields from the page and when you have too many fields to avoid scrolling. This feature may also give good user experience. I am assuming you already have some knowledge about jQuery and know a little of it. For details please visit <a title="jQuery" href="http://www.jquery.com" target="_blank">http://jquery.com </a></p>
<p>To do this I have used jQuery and did a bit hack in APEX html code. In this scenario, I have <strong>Revised Cost</strong> field and <strong>Reason for revision</strong> check boxes. Now I do not want to display the check boxes unless Revised Cost field is not empty and when user click on that field to enter data. Here is the screen capture of my page -</p>
<div id="attachment_133" class="wp-caption alignnone" style="width: 459px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/jquery_chk.jpg"><img class="size-full wp-image-133" title="Check boxes" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/jquery_chk.jpg" alt="" width="449" height="197" /></a><p class="wp-caption-text">APEX Page</p></div>
<div class="important_block message-block"><p class="printonly"><strong>Important!</strong></p><p class="poststats" class="first-p">This post has 22 words. It will take approximately 13 secondes for reading it.</p><p>I am actually using APEX 3.2 for this exercise. I am sure you could do it much more easier way in APEX 4.x. </p>
</div>
<p>Once the page is rendered, view the source code of the page. You can right click on the middle of screen and click on view source in Internet Explorer. In FireFox just right click on the middle of the page then click on view page source.</p>
<p>Now I am looking for the relevant html code for these fields. The code will look like this -</p>
<pre class="brush:php">&lt;input type="text" name="p_t29" size="12" maxlength="2000" id="P3_FAC_REVISED_COST"
        value="332" /&gt;
    &lt;div id="content"&gt;
    &lt;/div&gt;
    &lt;label for="P3_REASON_COST_REVISED"&gt;
        &lt;a style="text-decoration: none; font-weight: bold;" href="javascript:popupFieldHelp('23893628613382143','198940878990662')"
            tabindex="999"&gt;Reason for revision:&lt;/a&gt;&lt;/label&gt;
    &lt;fieldset id="P3_REASON_COST_REVISED" class="checkbox_group"&gt;
        &lt;input type="checkbox" name="p_v31" value="INITIAL_UNKNOWN" id="P3_REASON_COST_REVISED_0" /&gt;&lt;label
            for="P3_REASON_COST_REVISED_0"&gt;Initial cost is unknown&lt;/label&gt;&lt;br /&gt;
        &lt;input type="checkbox" name="p_v31" value="DIFFERENT_DESIGN" id="P3_REASON_COST_REVISED_1" /&gt;&lt;label
            for="P3_REASON_COST_REVISED_1"&gt;New asset will have different design or materials&lt;/label&gt;&lt;br /&gt;
        &lt;input type="checkbox" name="p_v31" value="TODAYS_INACCURATE" id="P3_REASON_COST_REVISED_2" /&gt;&lt;label
            for="P3_REASON_COST_REVISED_2"&gt;Today's cost was inaccurate&lt;/label&gt;&lt;br /&gt;
    &lt;/fieldset&gt;</pre>
<p>&nbsp;</p>
<p>Now examine the above code, all the check boxes are inside the fieldset. I can actually hide the whole field set instead of individual check boxes. You can hide individual check boxes if you want. I also have to hide the relevant label to hide/show based on the value of the text field.</p>
<p>Place the following javascript in the header section or footer section of the page -</p>
<pre class="brush:javascript">&lt;script type="text/javascript"&gt;
$(document).ready(function () {

        // get the text field value
        var pr = $('#P3_FAC_REVISED_COST').val();

        if (pr.length === 0) {
            //hide the label if above condition matches
            $("label[for=P3_REASON_COST_REVISED],#P3_REASON_COST_REVISED").hide();
            //hide the text field if above condition matches
            $('#P3_REASON_COST_REVISED').hide();
        }

        $('#P3_FAC_REVISED_COST').click(function () {

            //for new entry I want to show the fields if user click on the text field

            $("label[for=P3_REASON_COST_REVISED],#P3_REASON_COST_REVISED").show();
            $('#P3_REASON_COST_REVISED').show();

        });

    });

&lt;/script&gt;</pre>
<p>&nbsp;</p>
<p>The page in action now -</p>
<p>&nbsp;</p>
<p><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/jquery_chk1.jpg"><img class="alignnone size-full wp-image-134" title="Hide checkbox" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/jquery_chk1.jpg" alt="" width="313" height="126" /></a></p>
<p>But when the field has some values, it does not hide any more -</p>
<p><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/jquery_chk2.jpg"><img class="alignnone size-full wp-image-135" title="Not hidden" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/jquery_chk2.jpg" alt="" width="459" height="193" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/hide-checkbox-group-in-apex-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counting record and sorting with fiscal month in APEX chart</title>
		<link>http://saradesh.com/tajuddin/index.php/counting-record-and-sorting-with-fiscal-month-in-apex-chart/</link>
		<comments>http://saradesh.com/tajuddin/index.php/counting-record-and-sorting-with-fiscal-month-in-apex-chart/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 05:32:57 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[APEX]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=110</guid>
		<description><![CDATA[This post has 620 words. It will take approximately 6 minutes, 12 secondes for reading it.Recently in one of my project that built in Oracle APEX. This is basically a Change Request System (CRS) built in APEX to submit or log any change request by system users for other corporate systems. It was working quite &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/counting-record-and-sorting-with-fiscal-month-in-apex-chart/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 643 words. It will take approximately 6 minutes, 25 secondes for reading it.</p><p>Recently in one of my project that built in Oracle APEX. This is basically a Change Request System (CRS) built in APEX to submit or log any change request by system users for other corporate systems. It was working quite well with the notification and reporting. When user submit a new request I get an email notification and then I access to the CRS to review and action the request. User who originally posted the request get notified every time I do changes in the request log and get update about the progress of the request.</p>
<p>I thought it will be good to have some sort of summary report with chart to see how many calls logged each month and how much change we do in the system. Started to create a new page with chart and scripted my simple query in TOAD first to make sure the script written correctly. Here is my initial script to implement chart -</p>
<pre class="brush:sql">-- To count records for each month
SELECT NULL Link, TO_CHAR (create_date, 'MON/YY') AS "Month", COUNT (*) AS "No of records"
    FROM RT_RFC
GROUP BY TO_CHAR (create_date, 'MON/YY')
ORDER BY TO_CHAR (create_date, 'MON/YY')</pre>
<p>The query works well in TOAD and I have carried over the script to my APEX page. Here is what I get output from my chart.</p>
<div id="attachment_111" class="wp-caption alignnone" style="width: 657px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/chart.jpg"><img class="size-full wp-image-111" title="Chart Preview" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/chart.jpg" alt="" width="647" height="476" /></a><p class="wp-caption-text">APEX Flash Chart</p></div>
<p>Ops! I did not realize that the chart was not rendering months according to fiscal year instead it was rendering alphanumerically. Actually it was doing the same in TOAD but I did not notice in first instance. This is not going to help and I can see why it was sorting alphanumerically because I was converting date to char (string) <img src='http://saradesh.com/tajuddin/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .</p>
<p>I have tried different approach using <em>trunc</em>() and it works fine APEX standard report however I had set the column format to month in the report column heading to <em>&#8216;Month&#8217;</em> . Here is the truncate statement -</p>
<pre class="brush:sql"> SELECT NULL link, TRUNC (create_date, 'MONTH') AS "Month", COUNT (*)
    FROM rtt_rfc
GROUP BY TRUNC (create_date, 'MONTH')</pre>
<p>When I have implemented this code in Chat control it was displaying &#8217;1-MAY-2010&#8242; which is what I do not want to display like. I want to display only Month name. Here is what I got with this script -</p>
<div id="attachment_112" class="wp-caption alignnone" style="width: 660px"><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/chart1.jpg"><img class="size-full wp-image-112" title="Flash Chart" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/chart1.jpg" alt="" width="650" height="651" /></a><p class="wp-caption-text">Flash Chart in APEX</p></div>
<p>As you can see I have change the rotation to display the month in 45 degree rotation but unfortunately I could not find any way to format the month field to display only month. I had to think for alternate solution.</p>
<p>Ok, I suddenly thought how about if I use case statement to achieve this. Here is what I have done -</p>
<pre class="brush:sql">SELECT NULL link,
         CASE
            WHEN TO_CHAR (create_date, 'MM') = 1 THEN 'JAN'
            WHEN TO_CHAR (create_date, 'MM') = 2 THEN 'FEB'
            WHEN TO_CHAR (create_date, 'MM') = 3 THEN 'MAR'
            WHEN TO_CHAR (create_date, 'MM') = 4 THEN 'APR'
            WHEN TO_CHAR (create_date, 'MM') = 5 THEN 'MAY'
            WHEN TO_CHAR (create_date, 'MM') = 6 THEN 'JUN'
            WHEN TO_CHAR (create_date, 'MM') = 7 THEN 'JUL'
            WHEN TO_CHAR (create_date, 'MM') = 8 THEN 'AUG'
            WHEN TO_CHAR (create_date, 'MM') = 9 THEN 'SEP'
            WHEN TO_CHAR (create_date, 'MM') = 10 THEN 'OCT'
            WHEN TO_CHAR (create_date, 'MM') = 11 THEN 'NOV'
            WHEN TO_CHAR (create_date, 'MM') = 12 THEN 'DEC'
         END
            "MONTH",
         COUNT (*) AS "No of Request"
    FROM rtt_rfc
GROUP BY TO_CHAR (create_date, 'MM')
ORDER BY TO_CHAR (create_date, 'MM')</pre>
<p>Hmm, it is looking good in TOAD when ran the query and doing exactly what I wanted to do. Now I took the query into the chart report. Here is what I got -</p>
<p>&nbsp;</p>
<p><a href="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/chart2.jpg"><img class="alignnone size-full wp-image-113" title="Flash Chart" src="http://saradesh.com/tajuddin/wp-content/uploads/2012/01/chart2.jpg" alt="" width="635" height="691" /></a></p>
<p>Wow! it is working perfect now. Hope this will help someone to play around with date field.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/counting-record-and-sorting-with-fiscal-month-in-apex-chart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing AJAX keyword search from database table</title>
		<link>http://saradesh.com/tajuddin/index.php/implementing-ajax-keyword-search-from-database-table/</link>
		<comments>http://saradesh.com/tajuddin/index.php/implementing-ajax-keyword-search-from-database-table/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 06:49:29 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[gridview]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[text search]]></category>

		<guid isPermaLink="false">http://saradesh.com/tajuddin/?p=71</guid>
		<description><![CDATA[This post has 679 words. It will take approximately 6 minutes, 47 secondes for reading it.In this exercise, I will demonstrate how to implement a simple keyword search in MS SQL Server database using textbox and gridview control in Asp.NET AJAX technology. Most of the websites now use AJAX technology to avoid the full postback &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/implementing-ajax-keyword-search-from-database-table/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 698 words. It will take approximately 6 minutes, 58 secondes for reading it.</p><p>In this exercise, I will demonstrate how to implement a simple keyword search in MS SQL Server database using textbox and gridview control in Asp.NET AJAX technology. Most of the websites now use AJAX technology to avoid the full postback and better user experience. It is wonderful, personally I love it. To begin with this exercise I assume you have a SQL Express or SQL Server database installed. I will use global connection string from web.config file. The connection string in my web config file pointing the SQL Express database located in App_Data folder. Here is the connection string -</p>
<pre class="brush:xml">&lt;connectionStrings&gt;
  &lt;!--Your connection string for database--&gt;
  &lt;add name="myConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=¦DataDirectory¦\practice.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/&gt;   

&lt;/connectionStrings&gt;</pre>
<p>Now, in the default.aspx page. I have created a textbox control and a submit button to trigger the query when something entered in the input textbox. I also have created a simple validation control and validation summary control to force user to type anything in the textbox before submitting the page on button click. I also have created a gridview control to display the query data. In this exercise I have not selected any specific column in the gridview control so that  it will display all columns from the source table.Here is what I have done -</p>
<pre class="brush:xml">&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt;     

&lt;div&gt;         

&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
&lt;ContentTemplate&gt;
&lt;p&gt;Enter employee last name and click on submit button to search. You can enter a few letters of the employee last name to search.&lt;/p&gt;
&lt;asp:ValidationSummary ID="ValidationSummary1" runat="server" /&gt;
Last Name: &lt;asp:TextBox ID="txtName" runat="server" /&gt;
&lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="You must enter a name."             ControlToValidate="txtName"&gt;*&lt;/asp:RequiredFieldValidator&gt;
&lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" /&gt;             

&lt;p&gt;Display result here.&lt;/p&gt;
&lt;asp:GridView ID="GridView1" runat="server"&gt;
&lt;/asp:GridView&gt;
&lt;/ContentTemplate&gt;         

&lt;/asp:UpdatePanel&gt;         

&lt;asp:UpdateProgress ID="UpdateProgress1" runat="server"&gt;
        &lt;ProgressTemplate&gt;
                &lt;img src="loading.gif" /&gt;
        &lt;/ProgressTemplate&gt;
&lt;/asp:UpdateProgress&gt;         

&lt;/div&gt;          

&lt;asp:SqlDataSource ID="dsEmployee" runat="server" ConnectionString="&lt;%$ ConnectionStrings:myConnection %&gt;"
SelectCommand="SELECT * FROM emp WHERE (lastName like @LastName+'%')"&gt;
    &lt;SelectParameters&gt;
        &lt;asp:ControlParameter Name="LastName" ControlID="txtName" type="String" /&gt;
    &lt;/SelectParameters&gt;
&lt;/asp:SqlDataSource&gt;</pre>
<p>&nbsp;</p>
<p><span style="color: #993300;"> <div class="important_block message-block"><p class="printonly"><strong>Important!</strong></p><p class="poststats" class="first-p">This post has 17 words. It will take approximately 10 secondes for reading it.</p><p></span><span style="color: #993300;">Note, inside update progress template I am using an image to display while fetching the gridview result.</span><span style="color: #993300;"></p>
</div></span></p>
<p>Now I have to create an event for submit button. I have created an event handler for submit button so that it will be triggered when button is clicked by user. It is very simple event here, I have indicated the datasource for Gridview control and then bind data. When button is clicked, dataSourceID gets select parameter value from the textbox control and refine the search accordingly.</p>
<pre class="brush:vb">Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click         

	'selecting the datasource for gridview1 on button click event
	GridView1.DataSource = dsEmployee
	'Bind data to gridview
	GridView1.DataBind()
End Sub</pre>
<p>&nbsp;</p>
<p>I have saved the page, and right click on the default.aspx page, click on view in browser. Here you got a simple ajax keyword search engine. Type a latter of a name  and click on submit button it will display all the records starting the last name with that letter.</p>
<p>You can also bind the the specific column/s to the gridview if you do not want to display all records from the table. Make sure you have set the AutoGenerateColumns to false  in Gridview like below -</p>
<pre class="brush:xml">&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="empId"&gt;             

    &lt;Columns&gt;
        &lt;asp:BoundField DataField="FirstName" HeaderText="First Name" /&gt;
        &lt;asp:BoundField DataField="LastName" HeaderText="Last Name" /&gt;
    &lt;/Columns&gt;
&lt;/asp:GridView&gt;</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/implementing-ajax-keyword-search-from-database-table/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rename files in file directory using asp.net</title>
		<link>http://saradesh.com/tajuddin/index.php/rename-files-in-file-directory-using-asp-net/</link>
		<comments>http://saradesh.com/tajuddin/index.php/rename-files-in-file-directory-using-asp-net/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 05:00:28 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[rename file]]></category>

		<guid isPermaLink="false">http://tajuddin.chittagong-it.com/?p=37</guid>
		<description><![CDATA[This post has 280 words. It will take approximately 2 minutes, 48 secondes for reading it.In this example of I will show how to rename all the files in a directory using asp.net. Sometimes you may have thousands of photos that require to rename or add extention at the end the file name. I have &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/rename-files-in-file-directory-using-asp-net/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 280 words. It will take approximately 2 minutes, 48 secondes for reading it.</p><p>In this example of I will show how to rename all the files in a directory using asp.net. Sometimes you may have thousands of photos that require to rename or add extention at the end the file name. I have used very simple script to rename all the files in a folder with button click event.</p>
<p>First I have inserted a button in my default.aspx page and named that btnRename. In this example I want to add .gif extention with all the files in that folder as currently those files does not have any extention. For the onClick event of that button I have included the following script -</p>
<p><strong>VB Code:</strong></p>
<p>&nbsp;</p>
<pre class="brush:vb">Protected Sub btnRename_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRename.Click
        Dim source As String
        Dim i As String = 0

        'Folder to rename files
        source = Server.MapPath("~/test/")

        For Each fName As String In Directory.GetFiles(source)
            Dim dFile As String = String.Empty
            dFile = Path.GetFileName(fName)
            Dim dFilePath As String = String.Empty
            dFilePath = source + dFile
            Dim fi As New FileInfo(dFilePath)
            fi.MoveTo(source + dFile + ".gif") 'adding extention .gif with the actual file name

        Next
        i = Nothing

    End Sub</pre>
<p>If you are using C# then make sure you include onClick event for the specified button -</p>
<pre class="brush:csharp">protected void btnRename_Click(object sender, System.EventArgs e)
{
    string source = null;
    string i = 0;

    //Folder to rename files
    source = Server.MapPath("~/test/");

    foreach (string fName in Directory.GetFiles(source)) {
        string dFile = string.Empty;
        dFile = Path.GetFileName(fName);
        string dFilePath = string.Empty;
        dFilePath = source + dFile;
        FileInfo fi = new FileInfo(dFilePath);
            //adding extention .gif with the actual file name
        fi.MoveTo(source + dFile + ".gif");
    }

    i = null;
}</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/rename-files-in-file-directory-using-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing ASP.NET Membership Schema in SQL Server 2005/2008</title>
		<link>http://saradesh.com/tajuddin/index.php/installing-asp-net-membership-schema-in-sql-server-20052008/</link>
		<comments>http://saradesh.com/tajuddin/index.php/installing-asp-net-membership-schema-in-sql-server-20052008/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 04:38:09 +0000</pubDate>
		<dc:creator>tajuddin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[membership]]></category>
		<category><![CDATA[registration]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[user management]]></category>

		<guid isPermaLink="false">http://tajuddin.chittagong-it.com/?p=27</guid>
		<description><![CDATA[This post has 560 words. It will take approximately 5 minutes, 36 secondes for reading it.Before starting this tutorial, assuming that you have installed SQL Server 2005 or SQL server 2008 installed in your local machine. If you have not installed either one of those you can download a trial version from http://www.microsoft.com/sql website. However &#8230; </p><p><a class="more-link block-button" href="http://saradesh.com/tajuddin/index.php/installing-asp-net-membership-schema-in-sql-server-20052008/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p class="poststats">This post has 572 words. It will take approximately 5 minutes, 43 secondes for reading it.</p><p>Before starting this tutorial, assuming that you have installed SQL Server 2005 or SQL server 2008 installed in your local machine. If you have not installed either one of those you can download a trial version from <a href="http://www.microsoft.com/sql" target="_blank">http://www.microsoft.com/sql</a> website. However you can install the ASP.NET membership schema in SQL Express database as well.</p>
<h3>Varify SQL Server Database installation</h3>
<p>Once you have installed the SQL Server 2005 or 2008, restart your computer and open SQL Sever Management Studio (this is a UI tool which allows user to interact with the database easily). In the database explorer section, expand databases and you will see if there is any existing database. Right click on databases and click on new database, follow the prompt to create a new database.</p>
<p><a href="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/sqlServer.jpg"><img class="alignnone size-medium wp-image-28" title="SQL Server Management Tool" src="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/sqlServer-300x249.jpg" alt="SQL Server Management Tool" width="300" height="249" /></a></p>
<p>Once you created a blank database, you need to install ASP.NET membership schema to allow users to login to your website and register a new account and so on. It is very straight forward to install when you have microsoft .NET framework installed in your computer. To install ASP.NET membership schema browse the following location -</p>
<p><code>C:\WINDOWS\Microsoft.NET\Framework</code><br />
It shows all the framework version installed in your computer. Following image shows what it looks like. Double click on <strong>v2.0.50727</strong> folder -</p>
<p><a href="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/frameworks.jpg"><img class="size-medium wp-image-29" title=".NET Frameworks" src="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/frameworks-300x241.jpg" alt="ASP.NET Frameworks" width="300" height="241" /></a></p>
<div class="mceTemp">
<dl id="attachment_29" class="wp-caption alignnone" style="width: 310px;">
<dd class="wp-caption-dd">ASP.NET Frameworks</dd>
</dl>
</div>
<p>Find the executable file called &#8211; <strong> aspnet_regsql.exe</strong> and double click on it.</p>
<p><a href="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/aspnet_reqsql.jpg"><img class="size-medium wp-image-32" title="aspnet_reqsql file" src="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/aspnet_reqsql-300x241.jpg" alt="" width="300" height="241" /></a></p>
<div class="mceTemp">
<dl id="attachment_32" class="wp-caption alignnone" style="width: 310px;">
<dd class="wp-caption-dd">ASP.NET Membership registration file</dd>
</dl>
</div>
<p>It will open up the wizard and follow the on screen prompt to install asp.net membership schema in your desired database. Make sure your server address is correct and database is selected from the dropdown list. Once you installed the ASP.NET membership Schema, you can check it in the database explorer using SQL Server Management Studio tool. You will see all the membership tables and procedures are created, those tables has prefix with <strong>aspnet_</strong> -</p>
<div id="attachment_30" class="wp-caption alignnone" style="width: 310px"><a href="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/membership.jpg"><img class="size-medium wp-image-30" title="Membership Schema" src="http://tajuddin.chittagong-it.com/wp-content/uploads/2012/01/membership-300x249.jpg" alt="ASP.NET Membership Schema" width="300" height="249" /></a><p class="wp-caption-text">ASP.NET Membership Schema</p></div>
<h3>Configure ASP.NET Website</h3>
<p>Once you have installed ASP.NET membership schema, you are ready to go implementing the membership option in your website. You can just drag and drop any membership controls from login control in the toolbox. Before you start this you have to modify the connection string in web.config file so that it will direct the request to appropriate database. See the following image -</p>
<p>You can use windows integrated security for database connection string -</p>
<pre class="brush:xml">&lt;connectionstrings&gt;
  &lt;remove name="LocalSqlServer"&gt;
  &lt;add providername="System.Data.SqlClient" connectionstring="Data Source=KENS243-115\sqlexpress;Initial Catalog=whitepagesb;Integrated Security=True" name="LocalSqlServer" /&gt;
&lt;/connectionstrings&gt;</pre>
<p>You can also use custom membership provider in web.config file -</p>
<pre class="brush:xml">&lt;!-- Membership Provider --&gt;
&lt;membership userisonlinetimewindow="15" defaultprovider="UmbracoMembershipProvider"&gt;
&lt;providers&gt;
   &lt;add defaultmembertypealias="TestType" requiresquestionandanswer="false" enablepasswordreset="false" enablepasswordretrieval="false" type="umbraco.providers.members.UmbracoMembershipProvider" name="UmbracoMembershipProvider"&gt;
   &lt;add connectionstringname="LocalSqlServer" type="System.Web.Security.SqlMembershipProvider" name="AspNetSqlMemberShipProvider" /&gt;
   &lt;add requiresquestionandanswer="false" enablepasswordreset="false" enablepasswordretrieval="false" type="umbraco.providers.UsersMembershipProvider" name="UsersMembershipProvider" /&gt;
&lt;/membership&gt;</pre>
<p>Hope this will give you basic understanding how to install asp.net member schema in SQL Server 2005 or 2008.</p>
<p>There is an automated process comes with Visual Web Developer 2010. It will automatically creates the membership schema on you drag a membership control in the website and run the website. By default it uses the database file directory APP_DATA folder to store the database.</p>
]]></content:encoded>
			<wfw:commentRss>http://saradesh.com/tajuddin/index.php/installing-asp-net-membership-schema-in-sql-server-20052008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

