当前位置: 首页>>代码示例>>C#>>正文


C# Script.Serialization.JavaScriptSerializer.ToString方法代码示例

本文整理汇总了C#中System.Web.Script.Serialization.JavaScriptSerializer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Serialization.JavaScriptSerializer.ToString方法的具体用法?C# Script.Serialization.JavaScriptSerializer.ToString怎么用?C# Script.Serialization.JavaScriptSerializer.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Script.Serialization.JavaScriptSerializer的用法示例。


在下文中一共展示了Script.Serialization.JavaScriptSerializer.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckAvailability

        public string CheckAvailability(string userName)
        {
            try
            {
                using (SqlConnection sqlDBConnection = new SqlConnection(ConnectionString))
                {
                    StringBuilder sqlstmt = new StringBuilder("select EmployeeID, EmployeeName from [dbo].[EmployeeDB] where EmployeeName = @userName COLLATE Latin1_General_CS_AS ");
                    //sqlstmt.Append(Convert.ToString(userid));
                    SqlCommand myCommand = new SqlCommand(sqlstmt.ToString(), sqlDBConnection);
                    myCommand.CommandType = CommandType.Text;
                    myCommand.Parameters.AddWithValue("@userName", userName);

                    bool foundRecord = false;
                    sqlDBConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.Read())
                            foundRecord = true;
                        myReader.Close();
                    }
                    sqlDBConnection.Close();

                    object jsonObject = new { available = (!foundRecord) };
                    var json = new JavaScriptSerializer().Serialize(jsonObject);
                    return json.ToString();
                }
            }
            catch (Exception ex)
            {
                return string.Format("Exception : {0}", ex.Message);
            }
        }
开发者ID:srijanmishra,项目名称:iReserve,代码行数:32,代码来源:Service1.svc.cs

示例2: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     Autentificador recibido = new JavaScriptSerializer().Deserialize<Autentificador>(Request.Params["datos"]);
     Response.Write(recibido.ToString());
     Response.ContentType = "application/json";
     Response.End();
 }
开发者ID:MaybeGitHub,项目名称:Ajax-VisualStudio,代码行数:7,代码来源:autentificacion.aspx.cs

示例3: CheckAvailability

        public string CheckAvailability(string userName)
        {
            try
            {
                using (SqlConnection sqlDBConnection = new SqlConnection(ConnectionString))
                {
                    StringBuilder sqlstmt = new StringBuilder("select id,username,password,firstname,lastname,address,contactnumber,dateofbirth,emailid,securityquestion,answer,addressproof,photoidentity,status,rewardpoints from [dbo].[User] where username = @userName COLLATE Latin1_General_CS_AS ");
                    SqlCommand myCommand = new SqlCommand(sqlstmt.ToString(), sqlDBConnection);
                    myCommand.CommandType = CommandType.Text;
                    myCommand.Parameters.AddWithValue("@userName", userName);

                    bool foundRecord = false;
                    sqlDBConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.Read())
                            foundRecord = true;
                        myReader.Close();
                    }
                    sqlDBConnection.Close();

                    object jsonObject = new { available = (!foundRecord)};
                    var json = new JavaScriptSerializer().Serialize(jsonObject);
                    return json.ToString();
                }
            }
            catch (Exception ex)
            {
                return string.Format("Exception : {0}", ex.Message);
            }
        }
开发者ID:sunnyrajrathod,项目名称:OnePointTelecom,代码行数:31,代码来源:AvailabilityService.svc.cs

示例4: CheckAvailability

        public string CheckAvailability(string userName)
        {
            try
            {
                using (SqlConnection sqlDBConnection = new SqlConnection(ConnectionString))
                {
                    StringBuilder sqlstmt = new StringBuilder("SELECT COUNT(*) FROM Customer WHERE [email protected]");
                    //sqlstmt.Append(Convert.ToString(userid));
                    SqlCommand myCommand = new SqlCommand(sqlstmt.ToString(), sqlDBConnection);
                    myCommand.CommandType = CommandType.Text;
                    myCommand.Parameters.AddWithValue("@userName", userName);

                    bool foundRecord = false;
                    sqlDBConnection.Open();
                    int val = (int)myCommand.ExecuteScalar();
                    if (val >0)
                        foundRecord = true;

                    sqlDBConnection.Close();

                    object jsonObject = new { available = (!foundRecord) };
                    var json = new JavaScriptSerializer().Serialize(jsonObject);
                    return json.ToString();
                }
            }
            catch (Exception ex)
            {
                return string.Format("Exception : {0}", ex.Message);
            }
        }
开发者ID:namanbansal,项目名称:FashionableMe,代码行数:30,代码来源:Service1.svc.cs

示例5: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     // Creating Instance(object) of employee class
     Employee empObj = new Employee();
     
     // Assinging values to employee object
     empObj.FirstName = "Kannadasan";
     empObj.LastName = "Govindasamy";
     empObj.Designation = "Tech Lead"; ;
     empObj.Department = "Development";
     empObj.DOB.Date = 30;
     empObj.DOB.Month = 4;
     empObj.DOB.Year = 1988;
     
     // Serialize Employee Object
     var json = new JavaScriptSerializer().Serialize(empObj);
     Response.Write(json.ToString());
 }
开发者ID:dotnetpickles,项目名称:Serialization-Deserializaton-In-ASP.Net-C-.Net,代码行数:18,代码来源:Serialization.aspx.cs

示例6: CheckAvailability

        public string CheckAvailability(string userName)
        {
            try
            {
                string connectionString = ConfigurationManager.ConnectionStrings["databaseConnectionString"].ConnectionString;
                SqlConnection con = new SqlConnection(connectionString);
                con.Open();

                SqlCommand command = new SqlCommand("select count(*) from dbo.Users where username='" + userName + "';", con);
                SqlDataReader reader = command.ExecuteReader();
                reader.Read();

                bool isUserNameAvailable = (Convert.ToInt32(reader[0]) == 0 );

                object jsonObject = new { available = isUserNameAvailable };
                var json = new JavaScriptSerializer().Serialize(jsonObject);
                return json.ToString();
            }
            catch (Exception ex)
            {
                return string.Format("Exception : {0}", ex.Message);
            }
        }
开发者ID:IntellectCorp,项目名称:IntellectTechCareers,代码行数:23,代码来源:UserNameValidation.svc.cs

示例7: LogError

        public void LogError(long order_id,string err_subject, string err_msg,oCreateOrderRequest o, string ip)
        {
            try
            {
                email em = new email();
                em.SendEmail("[email protected]", "[email protected]", "", "[email protected]", "RedBubble endpoint", err_subject, err_msg, "smtp.yourself.com", "", "", "", false);
                using (var dc = new redbubbleDataContext())
                {
                    dc.sp_insert_orders_error_log(order_id, err_subject, err_msg, ip);
                }
            }
            catch { }

            try
            {
                var json = new JavaScriptSerializer().Serialize(o);
                using (var dc2 = new redbubbleDataContext())
                {
                    dc2.sp_update_ordrers_err_log_json(order_id, json.ToString());
                }
            }
            catch { }
        }
开发者ID:MichaelEvanchik,项目名称:RedBubble,代码行数:23,代码来源:redbubble.svc.cs

示例8: SaveUserPreferences

        private HttpResponseMessage SaveUserPreferences(UserPreference preferences, string user)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(ConfigurationManager.AppSettings["APIurl"] + "/api/UserPreference/SaveUserPreference");
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var json = new JavaScriptSerializer().Serialize(preferences);
            string urlParameters = "?user=" + user + "&preferences=" + json.ToString();

            HttpContent content = new StringContent("");
            HttpResponseMessage response = client.PostAsync(urlParameters, content).Result;

            return response;
        }
开发者ID:backpackerrecommender,项目名称:bapr,代码行数:14,代码来源:AccountController.cs

示例9: SerializeObject

 public String SerializeObject(Object obj)
 {
     var json = new JavaScriptSerializer().Serialize(obj);
     return json.ToString();
 }
开发者ID:persinac,项目名称:JobFinder,代码行数:5,代码来源:Utility.cs

示例10: LogOn

        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var json = new JavaScriptSerializer().Serialize(model);
                //if (Membership.ValidateUser(model.Email, model.Password))
                if(Http.HttpPost("http://localhost:8080/Auth/Validate", json.ToString()).Equals("\"ok\""))
                {
                    return RedirectToAction("Index", "Home");
                    //FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
                    //if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    //    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    //{
                    //    return Redirect(returnUrl);
                    //}
                    //else
                    //{
                    //    return RedirectToAction("Index", "Home");
                    //}
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:mdhari,项目名称:EBuster,代码行数:29,代码来源:AccountController.cs

示例11: Register

        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {

                // Attempt to register the user
                //MembershipCreateStatus createStatus;

                var json = new JavaScriptSerializer().Serialize(model);

                //Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
                //int createStatus = System.Convert.ToInt32(Http.HttpPost("http://localhost:8080/Auth", "{\"Email\":\"2147483647\",\"Password\":\"String content\"}"));
                int createStatus = System.Convert.ToInt32(Http.HttpPost("http://localhost:8080/Auth/Register", json.ToString()));

                if (createStatus == 0)
                {
                    //FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }else if(createStatus == 7)
                {
                    ModelState.AddModelError("", ErrorCodeToString(MembershipCreateStatus.DuplicateEmail));
                }
                else
                {
                ModelState.AddModelError("", ErrorCodeToString(new MembershipCreateStatus()));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:mdhari,项目名称:EBuster,代码行数:31,代码来源:AccountController.cs


注:本文中的System.Web.Script.Serialization.JavaScriptSerializer.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。