Easy ASP.NET jQuery Tutorial
jQuery ASP.NET HTML JavaScript VB C# Tutorial
Friday, May 31, 2013
Source Control Team Foundation Service Sign up for free.
This is a good way for keep safe your source code and compare with old version.
Wednesday, October 24, 2012
Easy jQuery Slideshow
Introduction
Hi all,
This is simple use for slideshow , We have 3 step for this.
Step 1: Add the JavaScript function
Copy and paste script below in your script tag.
var folder = "images"; var timeout = 4000; var StartPicc = 2; var EndPicc = 5; var timer; $(document).ready(function () { timer = setTimeout("EasySlideShow();", timeout); }); function EasySlideShow() { $("#imgshow").fadeOut('slow', function () { $("#imgshow").attr("src", folder + "/" + StartPicc.toString() + ".jpg"); $("#imgshow").fadeIn('slow') if (StartPicc < EndPicc) StartPicc++; else StartPicc = 1; }); clearTimeout(timer); timer = setTimeout("EasySlideShow();", timeout); }
Step 2: Add jQuery
Step 3: Add image to your folder
named folder to images
named picture to 1.jpg > xxx.jpg
Copy and paste script below in your script tag.
Enjoy Easy ASP.NET jQuery Demo ZomDev
Thursday, October 18, 2012
ASP.NET : Creating a Web Service.
This is a demo project for creating a Web Service by using Visual Studio 2010 create with two Tier concept.
1st Tier is WebSite
2st Tier is WebService site
I have create step by step to inform you.
If you not understand you can download source code from a bottom of this demo.
Step 1 : Add a WebService to your WebSite.
Step 2 : Crea Hello World Method (if not exist).
Step 3 : Add a new WebSite for call web service.
Step 4 : Add Web Reference to MainSite by click on your mainsite > Add Service Reference
Step 5 : Click Advance > Add Web Reference > WebService on this solution
It will find WebService on solution to show you and click WebService Name it to "WSTest"
Result : you will found generated file in solution.
Step 6 : Test calling a WebService.
The ResultI create method name GetString and return "Hello World + GetString" to display in page by using Response.Write.
Download create web service demo here
If you understnd how to create WebService already, Please visit How to using WebService via JavaScript/jQuery. for more information thank ^^
Enjoy ZomDev
ASP.NET : Update Data via JavaScript using ICallback
This sample will show how to update data via JavaScript.
Three Step to Show you
Step 1 : Implement Interface ICallbackEventHandler.
Step 2 : Declare public string to get GetCallbackEventReference.
Step 3 : Call it by assign to OnClientClick Button.
Code behine
public partial class ICallback_CS : System.Web.UI.Page,ICallbackEventHandler { public string CallbackScript = string.Empty; private string CallbackArg = string.Empty; protected void Page_Load(object sender, EventArgs e) { CallbackScript = Page.ClientScript.GetCallbackEventReference(Page, "arg", "onSuccessCallback", "context","onErrorCallback",false); } public string GetCallbackResult() { return string.Format("Update {0} Complete.", CallbackArg); } public void RaiseCallbackEvent(string eventArgument) { CallbackArg = eventArgument; } }
HTML
<body>
<form id="form1" runat="server">
<div >
<asp:TextBox ID="txt1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btCallback" runat="server" Text="UpdateData" OnClientClick="GetString(); return false;" />
</div>
</form>
</body>
<script type="text/javascript">
function GetString() {
var arg = $("#txt1").val();
var context = "";
<%=CallbackScript %>;
}
function onSuccessCallback(e){
alert(e);
}
function onErrorCallback(e){
alert(e);
}
</script>
ASP.NET : Update Data using jQuery JavaScript via WebService
This sample will show how to Update Data using jQuery JavaScript via WebService.
Step 1 : Create WebService Method.[WebMethod] public string UpdateData(string Data) { //Connect DataBase to Update Data return "Update '" + Data + "' successfully."; }Step 2 : Create JavaScript function using jQuery.ajax
function UpdateData() { $.ajax({ url: "WebService.asmx/UpdateData", data: "{ 'Data': '" + $("#txtData").val() + "' }", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { alert(data.d); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.responseText); } }); }Step 3 : Call it from Button OnClientClick.
enjoy ZomDev
<asp:TextBox ID="txtData" runat="server" ></asp:TextBox>
<br />
<asp:Button ID="btnUpdate" runat="server" Text="UpdateData" OnClientClick="UpdateData();return false;" />
ASP.NET : Send multiple value to Server using JSON
This sample will show how to Send multiple value to Server using JSON.
Step 1 : Create WebService Method.[WebMethod] public string GetData(string Data) { System.Web.Script.Serialization.JavaScriptSerializer JSON = new System.Web.Script.Serialization.JavaScriptSerializer(); Object obj = JSON.DeserializeObject(Data); Hashtable ht = new Hashtable(); foreach (KeyValuePairStep 2 : Create JavaScript function using jQuery.ajaxd in (Dictionary )obj) { ht.Add(d.Key, d.Value); } return "GetData successfully."; }
Declare Array type in JavaScript and serialize to JSON Data and pass value to WebService.
function SendData() { var arg = {}; arg["Data1"] = "String1"; arg["Data2"] = 950; arg["Data3"] = "String2"; arg = Sys.Serialization.JavaScriptSerializer.serialize(arg); $.ajax({ url: "WebService.asmx/GetData", data: "{ 'Data': '" + arg + "' }", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { alert(data.d); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.responseText); } }); }
WebService can get JSON data that send from jQuery.ajax
enjoy ZomDevFriday, October 12, 2012
ASP.NET : Test Async on ASP.NET 4.5 ** await new WebClient().DownloadStringTaskAsync(url)
ASP.NET : Test Async on ASP.NET 4.5
Hello , This is a simple way to read other website to display or get some html text data.
i seem like jQuery.load("website") but it manage by ASP.NET engine.
Before use Async we must set Async="true" on ' <@Page Async="true" '
2 Step Below include sourcecode again
Step 1 : Create button for fire event and Panel for disply data.
<asp:Button ID="btntest" runat="server" Text="Test" OnClick="btntest_Click" />
<asp:Panel ID="pnlTest" runat="server" GroupingText="testData">
<asp:Label ID="lbltest" runat="server"></asp:Label>
</asp:Panel>
Step 2 : Create Event and method.
public async void TestAsync() { string url = "http://www.asp.net"; string content = await new WebClient().DownloadStringTaskAsync(url); lbltest.Text = content; } protected void btntest_Click(object sender, EventArgs e) { TestAsync(); }Enjoy ASP.NET Zomdev.
What's New in ASP.NET 4.5 and Visual Studio 2012
Here is the information about latest ASP.NET for Visual Studio 2012.
Hope this can help everyone.
What's New in ASP.NET 4.5 and Visual Studio 2012
enjoy zomdev
Hope this can help everyone.
What's New in ASP.NET 4.5 and Visual Studio 2012
enjoy zomdev
ASP.NET Export DataTable to excel using GridView controls
Hello this project will export DataTable to *.xls file for excel.
You can modify GridView style for display colorful format in excel.
Another project for display data in excel.
ASP.NET : Export DataTable to CSV
Two Step include sourcecode below.
Step 1 : Design ASPX HTML.
Add Export Button and GridView with colorful format for display in excel
<asp:Button ID="btnExcel" runat="server" Text="Excel" /> <br /> <asp:GridView ID="gv1" runat="server" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" EnableModelValidation="True" GridLines="Horizontal"> <AlternatingRowStyle BackColor="#F7F7F7" /> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> </asp:GridView>
Step 2 : Create method and call in Button_Click event in codebehind.
Protected Sub btnExcel_Click(sender As Object, e As System.EventArgs) Handles btnExcel.Click ExportExcel2(TestData) End Sub Sub ExportExcel2(dt As DataTable) gv1.DataSource = TestData gv1.DataBind() Response.AddHeader("content-disposition", "attachment; filename=ExcelName.xls") Response.ContentType = "application/vnd.ms-excel" Response.Charset = "TIS-620" Me.EnableViewState = False Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) Dim frm As HtmlForm = New HtmlForm() Me.Controls.Add(frm) frm.Controls.Add(gv1) frm.RenderControl(hw) Response.Write(tw.ToString()) Response.End() End Sub
For export excel without format table please use method below
Sub ExportExcel(dt As DataTable) Dim GV As New System.Web.UI.WebControls.GridView GV.DataSource = TestData GV.DataBind() Response.AddHeader("content-disposition", "attachment; filename=ExcelName.xls") Response.ContentType = "application/vnd.ms-excel" Response.Charset = "TIS-620" Me.EnableViewState = False Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) Dim frm As HtmlForm = New HtmlForm() Me.Controls.Add(frm) frm.Controls.Add(GV) frm.RenderControl(hw) Response.Write(tw.ToString()) Response.End() End Sub
Pls enjoy ZomDev
Subscribe to:
Posts (Atom)