Tag: asp.net

INSERT与UPDATE

我有以下查询: SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[“chestionar”].ConnectionString); SqlCommand cmd = new SqlCommand(“INSERT INTO Raspunsuri Values(@raspuns,@cnp,@data,’1′,@ip,@idsesiune)”, con); cmd.Parameters.AddWithValue(“@cnp”, Session[“sesiune_cnp”]); cmd.Parameters.AddWithValue(“@raspuns”, textbox1.Text); cmd.Parameters.AddWithValue(“@data”, DateTime.Now.ToLocalTime()); cmd.Parameters.AddWithValue(“@ip”,ip); cmd.Parameters.AddWithValue(“@idsesiune”, id_sesiune); try { con.Open(); cmd.ExecuteNonQuery(); Response.Redirect(“User2.aspx”); } catch (Exception ex) { Console.WriteLine(“Error:” + ex); } finally { con.Close(); } 我需要的是看表中是否有任何记录,如果有更新,否则插入它。我怎么能实现呢?

如何从asp.net中的javascript调用codebehind函数?

我想使用javascript从我的代码后面调用一个函数。 我用下面的代码: function fnCheckSelection() { some script; window[“My”][“Namespace”][“GetPart”](null); } …其中”GetPart”是函数名称。 但是,这不起作用。 请帮帮我。

从MasterPage方法调用内容页面方法

可能重复: 从母版页类调用的内容页面类方法 我需要从主页面事件中访问内容页面方法。 我怎样才能做到这一点? Content Page: public partial class Call_Center_Main : System.Web.UI.Page { Page_Load(object sender, EventArgs e) { } public void MenuClick(string ClkMenu) { // Some Code } } MasterPage: public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { //How Can I […]

Asp.net ConnectionString以安全的方式

我无法在谷歌上得到满意的答案,他们是: ConnectionString比HttpRequest更安全吗? 在web.config文件中使用ConnectionString比在任何特定的aspx页面中使用更安全吗? 以及如何为高度安全的网站保护ConnectionString? 我很想知道这件事。

将数据显示到TextBox的Label OnTextChanged事件中

假设我在文本框100中输入代码,但是标签中的Pizza应该在标签中发短信 protected void Page_Load(object sender, EventArgs e) { } protected void txtMain_TextChanged(object sender, EventArgs e) { lblmain.text = txtcat.text; }

使用HTTPS和httpWebRequest

我发送httpwebrequests到paypal api服务器,这使用https。 我做了你通常用http请求做的正常事情,它起作用了。 我是否需要做一些特殊的事情才能正确使用https,或者在请求URL中指定https以使其正常工作? 谢谢! 顺便说一句,我的请求是从我的服务器发送的,因此加密它们并不像从客户端计算机发送它们那么重要,但我仍然想要做得对。

“获取或设置附件预期”是什么意思?

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; public partial class RepeaterEx2 : System.Web.UI.Page { SqlConnection cn = null; SqlDataAdapter da = null; DataSet ds = null; String strSqlQuery = String.Empty; protected void Page_Load(object sender, EventArgs e) { cn = new SqlConnection(); cn.ConnectionString = “Server=(local);Data base=TestDb;Uid=sa;Password=123”; if […]

将global.asax迁移到ASP.NET 5

几天前.NET Core RC1已经发布了,我在阅读了很多关于它之后第一次试了一下,我喜欢它,但它有点不同。 我正在尝试将一个小博客(内置MVC5)迁移到MVC 6和.NET Core。 这并不难,但我真的很难重新创建我在MVC 5中完全相同的global.asax设置,ASP.NET 5不再具有global.asax所以我无法弄清楚大多数设置的替代品是什么是? protected void Application_Start() { ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new RazorViewEngine()); MvcHandler.DisableMvcResponseHeader = true; AntiForgeryConfig.SuppressXFrameOptionsHeader = true; BundleConfig.RegisterBundles(BundleTable.Bundles); RouteConfig.RegisterRoutes(RouteTable.Routes); } protected void Application_BeginRequest() { Response.AddHeader(“X-Frame-Options”, “DENY”); } protected void Application_EndRequest() { if (Response.StatusCode != 301 && Response.StatusCode != 302) return; var targetUrl = Response.RedirectLocation.Replace(“ReturnUrl”, “url”); Response.RedirectLocation = targetUrl; } protected […]

如何为GoogleWebAuthorizationBroker.AuthorizeAsync设置return_uri?

我正在尝试在非MVC .NET Web应用程序中使用Google Calendar API 。 (这似乎是一个重要的区别。) 我试图在谷歌和Daimto的这个例子中使用这个例子中的代码以及来自这里的一些相关post的一些有用的提示。 我写了以下方法: public void GetUserCredential( String userName ) { String clientId = ConfigurationManager.AppSettings[ “Google.ClientId” ]; //From Google Developer console https://console.developers.google.com String clientSecret = ConfigurationManager.AppSettings[ “Google.ClientSecret” ]; //From Google Developer console https://console.developers.google.com String[] scopes = new string[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar }; // here is where we Request the user to […]

如何从usercontrol页面后面的代码中找到ListView的ItemTemplate中的控件?

实际上,我正在使用ASP.NET和C#开发一个Web模板。 我在usercontrol页面中有一个listview ,在ItemTemplate里面我有一个PlaceHolder ,如下所示: 我想从后面的代码访问这个PlaceHolder ,我使用不同的方法如下,但我无法访问它。 PlaceHolder ph_Lv_EditModule = (PlaceHolder)lv_Uc_Module.FindControl(“ph_Lv_EditModule”); 要么 PlaceHolder ph_Lv_EditModule = (PlaceHolder)this.lv_Uc_Module.FindControl(“ph_Lv_EditModule”); 你能帮我找一下如何在我的usercontrol页面后面的代码中找到这个控件。 感谢您的考虑。