<asp:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server" ForeColor="red" /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" /><br /> <asp:Button ID="Button1" runat="server" Text="Update Both Panels" OnClick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="Update This Panel" OnClick="Button2_Click" /> </ContentTemplate> </asp:UpdatePanel>
Thursday, October 17, 2013
Update Pannel
Tuesday, October 15, 2013
sql reader
public DataTable ExecuteRreader(string sp_name, Dictionary<string, object> parameters) { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) { SqlCommand sqlCommand = new SqlCommand(sp_name, sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; if (parameters != null) { foreach (KeyValuePair<string, object> parameter in parameters) sqlCommand.Parameters.AddWithValue(parameter.Key, parameter.Value); } DataTable dataTable = new DataTable(); sqlConnection.Open(); using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader()) { dataTable.Load(sqlDataReader); } return dataTable; } }
Sunday, October 13, 2013
autocomplete WebMothod with select event
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"> </script> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"> </script> <link type="text/css" rel="Stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script type="text/javascript"> $(document).ready(function() { $("#nameText").autocomplete({ source: function (request, response) { $.ajax({ url: "Default4.aspx/getdatas", data: "{strterm: '" + request.term + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { response($.map(data.d, function (item) { return { label: item.label , value: item.record, id: item.type, first: item.key, last: item.key } })) }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }, select: function (event, ui) { $("#TextBox1").val(ui.item.id); }, minLength: 1 }).data("ui-autocomplete")._renderItem = function (ul, item) { return $("<li></li>") .data("item.autocomplete", item) .append("<a>" + item.label + item.value + item.id + item.first + "</a>") .appendTo(ul); }; }); </script>
autocomplete jquery with select event
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"> </script> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"> </script> <link type="text/css" rel="Stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script type="text/javascript"> $(function () { var availableItems = [{ value: "recent", label: "Recent", classN: "heading" }, { value: "all", label: "All", classN: "all" }, { value: "lorem", label: "Lorem", classN: "lorem" }, ]; $(".post-to").autocomplete({ source: availableItems, minLength: 0, focus: function (event, ui) { $('.post-to').val(ui.item.label); alert(ui.item.label); return false; }, select: function (event, ui) { alert(ui.item.label); return false; } }).on("focus", function () { $(this).autocomplete("search", ''); }).data("ui-autocomplete")._renderItem = function (ul, item) { return $("<li></li>") .data("item.autocomplete", item) //instead of <span> use <a> .append("<a class='" + item.classN + "'></a><a>" + item.label + "</a>") .appendTo(ul); }; }); </script>
Wednesday, September 4, 2013
Crystal Report bind from source code
<div> <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" Height="1039px" Width="901px" /> </div> using System.Data.SqlClient; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.ReportSource; using CrystalDecisions.Shared; private ReportDocument rpt; protected void Page_Load(object sender, EventArgs e) { ConfigureCrystalReports(); string connection = @"DATA SOURCE=JOSE-PC\SQLEXPRESS;DATABASE=MedicalDB;Integrated Security=True;"; using (SqlConnection sqlConnection = new SqlConnection(connection)) { string query = "SELECT * FROM [MedicalDB].[dbo].[CrystalReport]"; SqlCommand sqlCommand = new SqlCommand(query, sqlConnection); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; DataSet ds = new DataSet(); sqlDataAdapter.Fill(ds); // ds.Tables[0].Rows[0]["Photo"] = (byte[])System.IO.File.ReadAllBytes(Server.MapPath("Penguins.jpg")); rpt.SetDataSource( ds.Tables[0]); CrystalReportViewer1.ReportSource = rpt; CrystalReportViewer1.RefreshReport(); } } private void ConfigureCrystalReports() { rpt = new ReportDocument(); string reportPath = Server.MapPath("CrystalReport.rpt"); rpt.Load(reportPath); ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.DatabaseName = "MedicalDB"; connectionInfo.IntegratedSecurity = true; //connectionInfo.UserID = ""; //connectionInfo.Password = "user123"; SetDBLogonForReport(connectionInfo, rpt); } private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument) { Tables tables = reportDocument.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables) { TableLogOnInfo tableLogonInfo = table.LogOnInfo; tableLogonInfo.ConnectionInfo = connectionInfo; table.ApplyLogOnInfo(tableLogonInfo); } } byte[] imgdata = System.IO.File.ReadAllBytes(HttpContext.Current.Server.MapPath(path)); create dataset and add fields to CrystalReport.rpt
Sunday, August 11, 2013
Bind DropDownList in Edit Footer And Empty templates
if (e.Row.RowType == DataControlRowType.DataRow && gridCategory.EditIndex ==e.Row.RowIndex) { string MenuName = ((HiddenField)e.Row.FindControl("hiddenMenuName")).Value; DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu"); bindddMenu(ddlMenu, MenuName); } else if (e.Row.RowType == DataControlRowType.Footer) { DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu"); bindddMenu(ddlMenu, ""); } else if (e.Row.RowType == DataControlRowType.EmptyDataRow) { DropDownList ddlMenu = (DropDownList)e.Row.Controls[0].Controls[0].FindControl("ddlMenu"); bindddMenu(ddlMenu, ""); } OR protected void gridCategory_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.EmptyDataRow) { DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu"); bindddMenu(ddlMenu, ""); } }
Thursday, August 8, 2013
CSS For Grid
<style type="text/css"> .grid { border:1px solid #111111; margin: 5px 0 10px 0; width:95%; font-size:1.2em; } .grid a:link { color:#114477; } .grid tr th { background-color:#336699; color:#FFFFFF; height:25px; font-weight:bold; } .grid tr, .grid th, .grid td { padding:5px; } .grid tr { background-color:#FFFFFF; color:#222222; } .grid tr.alt { background-color:#EDEDED; color:#222222; } .grid .pgr td { background-color:#bdbdbd; font-weight: bold; color:#555555; padding:1px; } .grid .pgr td a { padding:1px; } .grid .pgr td span { padding:1px; } </style>
Sunday, July 28, 2013
Forms Authentication
void Application_AuthenticateRequest(object sender, EventArgs e) { if (HttpContext.Current.User != null) { if (HttpContext.Current.User.Identity.IsAuthenticated) { if (HttpContext.Current.User.Identity is FormsIdentity) { FormsIdentity formsIdentity = (FormsIdentity)HttpContext.Current.User.Identity; string[] userRoles = formsIdentity.Ticket.UserData.Split(','); HttpContext.Current.User = new GenericPrincipal(formsIdentity, userRoles); } } } } protected void Login_Click(object sender, EventArgs e) { FormsAuthenticationTicket formsAuthenticationTicket = new FormsAuthenticationTicket(1, "abcd", DateTime.Now, DateTime.Now.AddMinutes(30), false, "Admin"); string encryptedFAT = FormsAuthentication.Encrypt(formsAuthenticationTicket); HttpCookie httpcookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedFAT); HttpContext.Current.Response.Cookies.Add(httpcookie); string returnURL = Request.QueryString["returnURL"]; if (returnURL == null) { Response.Redirect(returnURL); } else Response.Redirect("Default.aspx"); } <authentication mode="Forms"> <forms defaultUrl="Default.aspx" loginUrl="Login.aspx"> </forms> </authentication> <authorization> <allow roles="Admin"/> <deny users="*"/> </authorization>
Thursday, June 20, 2013
Jquery Image Gallery
<script type="text/javascript" src="script/jquery.1.9.min.js"></script> <script type="text/javascript"> var imageList; var start = 0; var autoImagesLoadID; $(document).ready(function () { $.ajax({ type: "POST", url: "Default.aspx/galleryPhotos", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { imageList = data.d; loadImages(imageList); autoImagesLoad(imageList); } }); function autoImagesLoad(imgList) { autoImagesLoadID = setInterval(function () { if (start + 1 > imgList.length) { start = 0; } else { start = start + 1; } $("#content > div.box > div.image > img").attr("src", "upload/" + imgList[start].photoPath); if (start % 5 == 0) { var $divthumbs = $("#content > div.box > div.thumbs").empty().append(""); for (var i = start; i < start + 5; i++) { if (imgList[i] && imgList[i].photoPath.length > 1) { var $div = $("<div/>").attr("class", "thumb").attr("title", imgList[i].rowID); var $divT = $("<div/>").attr("class", "imgthumb"); var $a = $("<a/>").attr("href", "javascript:;"); var $img = $("<img/>").attr("src", "upload/" + imgList[i].photoPath).appendTo($a); $divT.append($a).appendTo($div); $divthumbs.append($div); } } } $("#content > div.box > div.thumbs > div.thumb").css("background-color", ""); $("#content > div.box > div.thumbs > div.thumb[title~=" + (start + 1) + "]").css("background-color", "Blue"); }, 3000); } function loadImages(imgList) { $("#content > div.box > div.image > img").attr("src", "upload/" + imgList[start].photoPath); var $divthumbsTemp = $("<div/>"); for (var i = start; i < start + 5; i++) { if (imgList[i] && imgList[i].photoPath.length > 1) { var $div = $("<div/>").attr("class", "thumb").attr("title", imgList[i].rowID); if (i == 0) { $div.css("background-color", "Blue"); } var $divT = $("<div/>").attr("class", "imgthumb"); var $a = $("<a/>").attr("href", "javascript:;"); var $img = $("<img/>").attr("src", "upload/" + imgList[i].photoPath).appendTo($a); $divT.append($a).appendTo($div); $divthumbsTemp.append($div); } } $("#content > div.box > div.thumbs").empty().html($divthumbsTemp.html()); } $("#content > div.box > div.arrowleft").click(function () { if (start - 5 < 0) start = 0; else start = start - 5; $("#content > div.box > div.thumbs").animate({ "margin-right": "85%", height: "73px", width: "1px" }, "slow", function () { loadImages(imageList); }); $("#content > div.box > div.thumbs").animate({ "margin-right": "0%", height: "73px", width: "545px" }, "slow"); }); $("#content > div.box > div.arrowright").click(function () { if (start + 5 < imageList.length) start = start + 5; $("#content > div.box > div.thumbs").animate({ "margin-left": "85%", height: "73px", width: "1px" }, "slow", function () { loadImages(imageList); }); $("#content > div.box > div.thumbs").animate({ "margin-left": "0%", height: "73px", width: "545px" }, "slow"); }); $("#content > div.box > div.thumbs").on("mouseenter", "div.thumb", function () { start = ($(this).attr("title")) - 1; $("#content > div.box > div.image > img").attr("src", "upload/" + imageList[start].photoPath); $("#content > div.box > div.thumbs > div.thumb").css("background-color", ""); }); $("#content > div.box").mouseover(function () { clearInterval(autoImagesLoadID); }); $("#content > div.box").mouseout(function () { autoImagesLoad(imageList); }); }); </script> <!--begin pbox--> <div class="box"> <h3>Image Description</h3> <!-- begin post --> <div class="image"> <img src="" height="400px" width="640px" alt="" /></div> <!-- end post --> <div class="arrowleft"><a href="javascript:void(0)"><img src="images/left.png" alt="" /></a></div> <div class="thumbs"> </div> <div class="arrowright"><a href="javascript:void(0)"><img src="images/right.png" alt="" /></a></div> <div class="break"></div> </div> <!--end p bbox-->
Saturday, February 9, 2013
Create User In MVC Membership
if (ModelState.IsValid) { MembershipCreateStatus membershipCreateStatus; Membership.CreateUser(userRegistration.userName, userRegistration.password, userRegistration.emailID, userRegistration.securityQuestion, userRegistration.securityAnswer, true, out membershipCreateStatus); if (membershipCreateStatus == MembershipCreateStatus.Success) { Roles.AddUserToRole(userRegistration.userName, "UserRole"); return RedirectToAction("Index", "Account"); } else { ModelState.AddModelError("", "Registration Unsuccessful, Please Try again"); return View(userRegistration); } } else { return View(userRegistration); }
List Users In MVC Membership
CommonList commonList = new CommonList(); commonList.userName = ""; commonList.userList = Membership.GetAllUsers().Cast().Select(m => new UserList { userName = m.UserName, emailID = m.Email }).ToList();
Monday, January 28, 2013
Fill Dropdownlist in mvc
@Html.DropDownListFor(m => m.categoryList, new SelectList(Model.categoryList, "Value", "Text")) public IEnumerablecategoryList { get; set; } KochiDealsEntities1 db = new KochiDealsEntities1(); public IEnumerable fetchCategoryList() { var cat = (from m in db.ItemCategories select new { m.CategoryID,m.CategoryName }).AsEnumerable().Select(x => new SelectListItem { Value = x.CategoryID.ToString(), Text = x.CategoryName, Selected = true }); return cat; }
Thursday, January 17, 2013
Login with FaceBook
<script type="text/javascript"> // Load the SDK Asynchronously (function (d) { var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) { return; } js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); } (document)); // Init the SDK upon load window.fbAsyncInit = function () { FB.init({ appId: '198191300293654', // App ID channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File status: true, // check login status cookie: true, // enable cookies to allow the server to access the session xfbml: true // parse XFBML }); // listen for and handle auth.statusChange events FB.Event.subscribe('auth.statusChange', function (response) { if (response.authResponse) { // user has auth'd your app and is logged into Facebook FB.api('/me', function (me) { if (me.name) { document.getElementById('auth-displayname').innerHTML = me.name; } }) document.getElementById('auth-loggedout').style.display = 'none'; document.getElementById('auth-loggedin').style.display = 'block'; } else { // user has not auth'd your app, or is not logged into Facebook document.getElementById('auth-loggedout').style.display = 'block'; document.getElementById('auth-loggedin').style.display = 'none'; } }); $("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); }); } </script> <h1> Facebook Login Authentication Example</h1> <div id="auth-status"> <div id="auth-loggedout"> <div class="fb-login-button" autologoutlink="true" scope="email,user_checkins">Login with Facebook</div> </div> <div id="auth-loggedin" style="display: none"> Hi, <span id="auth-displayname"></span>(<a href="#" id="auth-logoutlink">logout</a>) </div> </div>
Tuesday, January 15, 2013
jquery tab
$("#existingCustomersTab").find("#customerDetailsDiv").tabs({ select: function (event, ui) { switch (ui.index) { case 0: //Create Ticket Tab break; case 1: //Ticket History Tab Starts var customerIDVal = $("#existingCustomersTab").find("#customerIDText").val(); if (customerIDVal != "") { $.ajax({ url: "CallRegister2.aspx/fetchTicketHistory", data: "{customerID:'" + customerIDVal + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { var $table = $('<table/>').css("border", "1px solid #111111"); ; var $tr = $('<tr/>').css("border", "1px solid #111111"); ; $tr.append("<th>").append("Complaint No").append("</th>").append("<th>").append("Subject").append("</th>").append("<th>").append("Status").append("</th>").append("<th>").append("Date").append("</th>"); $table.append($tr); $.each(data.d, function (i, item) { var $tr = $('<tr/>').css("border", "1px solid #111111"); ; var $a = $('<a/>').attr('href', 'javascript:void(0)').text(item.complaintNo).css('color', 'blue'); $tr.append("<td>").append($a).append("</td>").append("<td>").append(item.subject).append("</td>").append("<td>").append(item.status).append("</td>").append("<td>").append(item.date).append("</td>"); $table.append($tr); }); $("#existingCustomersTab").find("#ticketHistorySubTab").find("#ticketHistoryDiv").html($table); } }); } //Ticket History Tab Ends break; case 2: var customerIDVal = $("#existingCustomersTab").find("#customerIDText").val(); if (customerIDVal != "") { $.ajax({ url: "CallRegister2.aspx/fetchCustomerProfile", data: "{customerID:'" + customerIDVal + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data }, success: function (data) { $table = $("#existingCustomersTab").find("#profileSubTab").find("table").empty(); $table.last().append("<tr><th colspan='2'>Customer Profile</th></tr>"); $table.last().append("<tr><td>Service Provider</td><td>" + data.d[0].serviceProvider + "</td></tr>"); $table.last().append("<tr><td>Service ID</td><td>" + data.d[0].serviceID + "</td></tr>"); $table.last().append("<tr><td>First Name</td><td>" + data.d[0].firstName + "</td></tr>"); $table.last().append("<tr><td>Last Name</td><td>" + data.d[0].lastName + "</td></tr>"); $table.last().append("<tr><td>Email</td><td>" + data.d[0].email + "</td></tr>"); $table.last().append("<tr><td>Telephone</td><td>" + data.d[0].telephone + "</td></tr>"); $table.last().append("<tr><td>Street</td><td>" + data.d[0].street + "</td></tr>"); $table.last().append("<tr><td>City</td><td>" + data.d[0].city + "</td></tr>"); $table.last().append("<tr><td>State</td><td>" + data.d[0].state + "</td></tr>"); $table.last().append("<tr><td>Country</td><td>" + data.d[0].country + "</td></tr>"); $table.last().append("<tr><td>Zip</td><td>" + data.d[0].zip + "</td></tr>"); $table.last().append("<tr><td>Billing Address</td><td>" + data.d[0].billingAddress + "</td></tr>"); $table.last().append("<tr><td>Billing City</td><td>" + data.d[0].billingCity + "</td></tr>"); $table.last().append("<tr><td>Billing Zip</td><td>" + data.d[0].billingZip + "</td></tr>"); $table.last().append("<tr><td>Registered Date</td><td>" + data.d[0].regDate + "</td></tr>"); } }); } //Customer Profile Block break; default: //code to be executed if n is different from case 1 and 2 } } });
Auto Complete with ajax
$("#existingCustomersTab").find("#nameText").autocomplete({ source: function (request, response) { $.ajax({ url: "CallRegister2.aspx/fetchCustomerNames", data: "{reqNames: '" + request.term + "',lastNameChecked: '" + $("#existingCustomersTab").find('input[id=lastNameRb]:radio:checked').val() + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { response($.map(data.d, function (item) { return { label: item.firstName + " " + item.lastName, value: item.firstName + " " + item.lastName, id: item.id, first: item.firstName, last: item.lastName } })) }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }, select: function (event, ui) { $.ajax({ url: "CallRegister2.aspx/fetchCustomerDetails", data: "{txtId: '" + ui.item.id + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { $("#existingCustomersTab").find("#firstHiddenText").val(ui.item.first); $("#existingCustomersTab").find("#lastHiddenText").val(ui.item.last); $("#existingCustomersTab").find("#emailText").val(data.d[0].email); $("#existingCustomersTab").find("#customerIDText").val(ui.item.id); $("#existingCustomersTab").find("#phoneText").val(data.d[0].telephone); $("#existingCustomersTab").find("#accountIDText").val(data.d[0].serviceID); $("#existingCustomersTab").find("#customerDetailsDiv").tabs("option", "selected", 0); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }, minLength: 2, delay: 10 });
Dynamic acordian Jquery
function replyAccordion(complaintNo) { $("#existingCustomersTab").find("#ticketHistorySubTab").find("#complaintNoHidden").val(complaintNo); $.ajax({ url: "CallRegister2.aspx/fetchReply", data: "{complaintNo:'" + complaintNo + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", dataFilter: function (data) { return data; }, success: function (data) { var $div2 = $('<div/>'); var $h3 = $('<h3/>'); var $div = $('<div/>'); var $p = $('<p/>'); var $textarea = $('<TextArea/>').attr('id', 'replyTextArea').css('width', '325px'); var $select = $('<Select/>').attr('id', 'statusSelect2').append(statusStr); var $select2 = $('<Select/>').attr('id', 'repliedBySelect').append("<option value='Executive'>Executive</option><option value='Customer'>Customer</option>"); var $button = $('<Input/>').attr('value', 'Post Reply').attr('type', 'button').attr('id', 'replyButton'); $h3.append("Reply Post").append("| ComplaintNo:").append(complaintNo).append("| Status:").append(""); $p.append($textarea).append("<br />").append($select2).append($select).append($button); $div.append($p); $div2.append($h3).append($div); $.each(data.d, function (i, item) { var $h3 = $('<h3/>'); var $div = $('<div/>'); var $p = $('<p/>'); $h3.append("Replied By:").append(item.repliedBy).append("| On:").append(item.replyDate).append("| Status:").append(item.ticketStatus); $p.append(item.reply); $div.append($p); $div2.append($h3).append($div); }); $div2.accordion({ active: 0, autoHeight: false }); $("#existingCustomersTab").find("#ticketHistorySubTab").find("#ticketHistoryAccordion").empty().append($div2); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }
Pouse Resume Jquery Function
var i = 0; var intervalFunction = function () { $("#slider").find("#gallery").find("a").find("img").attr("src", arrLinks[i++].image); } var intervalID = window.setInterval(intervalFunction, 2000); $("#slider").find("#gallery").find("a").find("img").mouseover(function () { window.clearInterval(intervalID); }); $("#slider").find("#gallery").find("a").find("img").mouseleave(function () { intervalID = window.setInterval(intervalFunction, 2000); });
Subscribe to:
Posts (Atom)