Wednesday, November 28, 2012

Jquery Alert Box

As you can see in the below script, i just have added a jquery plug-in to my application for jquery classes.The jquery /Javascript provides alert box to display the desired data on dialog box.
<script src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script>
<script type="text/javascript">
    $(document).ready(function () {
        alert('Jquery Alert Box');
    });
</script>
<html>
<head><title>Jquery Alert</title></head>
<body>
</body>
</html>
you can excute the script by the time of page using Doument.ready function

String to DataTable in asp.net using C#.Net

Title:How to bind data table using string array in asp.net using c#

Description:
We have already learnt data binding to data source controls.Now i would like to show how would we use the array list to bind the data to grid view etc.

Examples:
Some  examples for JQuery Auto complete text boxhow to bind or Export CSV data to data table in asp.net.The below example describes the logic of iteration of array list to  data table.In the below i have used a string array to hold the string data and a grid view to display the resultant data of Data table.
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:GridView ID="GvOrdr" runat="server"></asp:GridView>
</asp:Content>

DataTable dtOrdrName = new DataTable();
dtOrdrName.Columns.Add(new DataColumn("Name", typeof(string)));
string[] strSplitOp = new string[] { "bhaskar", "Siva", "Ram" };
for (int i = 0; i <= strSplitOp.Length - 1; i++)
{
DataRow NewDrow = dtOrdrName.NewRow();
NewDrow["Name"] = strSplitOp[i].ToString();
dtOrdrName.Rows.Add(NewDrow);
}
GvOrdr.DataSource = dtOrdrName;
GvOrdr.DataBind();

Saturday, November 24, 2012

UniqueId and ClientID in asp.net

Here i have given two scenarios to explain those importance in asp.net
In case of a control which is placed in a web form without Master Page:
The Id and Name attribute rendered to the browser are same as Id of control on server and thus the same Id/Name can be used

for programming a control in java script

In case of a control which is placed in a web form with Master Page:

The control Client side Id="<%=ServerofControl.ClientID%>" example:ct100_ContentPlaceHolderId_ServerIdofControl

The control Client side Name="<%=ServerofControl.UniqueID%>" example:ct100$ContentPlaceHolderId$ServerIdofControl

1.Add a text box and HTML button to webform/content page which has been page
<asp:TextBox runat="server" ID="txtwform"/>

<input type="button" value="cbutton" onclick="Show()"/>

2.Add the following to the web form (cphHead isId of ContentPaveHolder added to Head Section of Master Page)
<asp:Content ID="chead" ContentPlaceHolderID="cphead" runat="server">

<script>
function Show()
{
var test=document.<%=Page.Form.ame%>.<%=txtwform.UniqueID%>;
alert(test.value);
}
</scrip>

Thursday, November 22, 2012

How to create object reference in Wpf

The creation of object reference in wpf will be easy when we compare with previous version of XAML.In previous versions we have to declare and binding Element name .In updated XAML we can used X:Reference to create object reference
<Label Target="{Binding ElementName=OId}">OrderId</Label>
<TextBox x:Name="Oid" />

 updated version:
<Label Target="{x:Reference Oid}">OrderId</Label>
<TextBox x:Name="Oid" />
<Label Target="{x:Reference Oname}">OrderName</Label>
<TextBox x:Name="Oname" />
<Label Target="{x:Reference Oslaes}">Sales</Label>
<TextBox x:Name="Osales" />
 
Note:The XAML X:Reference can supported in WPF frame work.In  XAML 2006 we have to use binding to reference the object
 

Wednesday, November 21, 2012

Difference between literal and label control in asp.net

Most of you confused when work these control.Because both controls are used to display the text.But there are some difference between those controls .
Main Difference:
Label control will display text in span tag .So we can apply styles to it.But literal control rendered out only text.Here i will show an example for how they behave in application



Tuesday, November 20, 2012

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint

It Will happen when the primary key Field has null value which has been referenced to child table with foreign key relation.To avoid these kind of errors we need get the records which has null value in parent table.To get those details we need to use the below query .

select  * from Order O LEFT JOIN Sales s on O.Order_Id= s.Order_Id
WHERE s.Order_Id is null

If you are not get any data using this query ,we can solve in other using below queries

Second Method:
First i will get the records  which is not null  using foreign key filed.Then i will check the FK value with PK values .If any FK is referenced to null i will update record with existing PK value
select *from order where order_id is not null
update order  set order_id=4 where order_id=5

 

Jquery UI autocomplete text box in Asp.net

In previous articles we have seen how to develop a Ajax autocomplete text box,Validate Asp.net dropdownlist using Jquery,Get dropdownlist selected value in Jquery,Allow only Numbers to textbox.Here i will show how to create a text box with auto complete using JqueryUI.Whenever use the jquery ,we need to add the jquery reference libraries to our application.In below i have been used jquery libraries(JqueryUI)and css to this task. In jquery i just create a array withe elements,then it will be assign to text box using auto complete .
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
var Keyword_Data = ["Share point","Sharepoint2010","Asp.Net","Asp","Csharp","Dotnet","MVC","MVC4","Jquery","Vb",
"Vb.Net","Sql Server","SQLSERVER 2012","Sliver Light"];
$("#<%= autoc1.ClientID %>").autocomplete({
source: Keyword_Data
});
});
</script>
Aspx:
Autocomplete textbox using jquery
<div>
<form id="UIform2" runat="server">
<asp:label id="tex" runat="server" text="Technology:"></asp:label>
<asp:textbox id="autoc1" runat="server"></asp:textbox>
</form>
</div>

Sunday, November 18, 2012

Machine.Config and web.config


Machine.Config

The config files are used to give the instructions to the web pages,all config files are implemented using XML .using XML files we can give the instructions at the design time as well as at the run time. The machine.config file is web server level any wrong modification having in the machine.config file we Can not execute  any asp.net application

web.config:

Using web.config file we can give programmer defined instructions to the web pages.The web.config file is application level in the web application .We can work with multiple web.config files,when any wrong modifications having in the web.config file we can not execute current application only

Monday, November 12, 2012

How to disable client side validation in sharepoint 2010

The validation controls are used get the right input from users.so i have used four validation controls for four text boxes in my web part.Then i was disable those validation based on page mode on server side.If the mode is display mode i will turn on all the validations on site.To turn on the validations we have to set the EnableClientScript property to false
WebPartManager wpmr = WebPartManager.GetCurrentWebPartManager(Page);
Respose.Write(wpmr.DisplayMode);
if (wpmr.DisplayMode == WebPartManager.EditDisplayMode)
{
ReOrderName.EnableClientScript = false;
RaOrderQuantity.EnableClientScript = false;
ReOrderAmt.EnableClientScript = false;
RaOrderAmt.EnableClientScript = false;
}
else if(wpmr.DisplayMode == WebPartManager.DesignDisplayMode)
{
ReOrderName.EnableClientScript = True;
ReOrderAmt.EnableClientScript = True;
}

Bel