小编G G*_* Gr的帖子

怎么做回发Javascript,jquery

<asp:Button ID="btn" OnClientClick="if(confirm_delete()){
/* post back*/
}else{
return false;
};" OnClick="btnDelete_Click" runat="server" Text="delete"/>
Run Code Online (Sandbox Code Playgroud)

嗨,我有这个代码,但我不能回复它,我不知道如何?

是吗:

<script type="text/javascript"> 
        function CallServer() {
            __doPostBack('not sure what goes here','or here');
        }  
</script>
Run Code Online (Sandbox Code Playgroud)

然后:

<asp:Button ID="btn" OnClientClick="if(confirm_delete()){
/CallServer()/
}else{
return false;
};" OnClick="btnDelete_Click" runat="server" Text="delete"/>
Run Code Online (Sandbox Code Playgroud)

我的另一个脚本:

<script type="text/javascript">
    function confirm_delete()
{
  if (confirm("Are you sure you want to delete this comment?")==true)
    return true;
  else
    return false;
}
</script>
Run Code Online (Sandbox Code Playgroud)

编辑:

在服务器端,我动态地将div添加到我的页面,其中包含来自我的数据库的内容,每个内容都会添加一个新的div,然后每个div都会使用idWallPosting(因此我可以调用我的删除功能)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Odbc;
using …
Run Code Online (Sandbox Code Playgroud)

javascript asp.net jquery

3
推荐指数
1
解决办法
4万
查看次数

未声明的标识符?

继续使用代码获取错误,这是从旧版VS到2010版的转换:

#include <string>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <math.h>

using std::string;

#define CROSSOVER_RATE            0.7
#define MUTATION_RATE             0.001
#define POP_SIZE                  100           //must be an even number
#define CHROMO_LENGTH             300
#define GENE_LENGTH               4
#define MAX_ALLOWABLE_GENERATIONS   400

//returns a float between 0 & 1
#define RANDOM_NUM      ((float)rand()/(RAND_MAX+1))

//----------------------------------------------------------------------------------------
//
//  define a data structure which will define a chromosome
//
//----------------------------------------------------------------------------------------
struct chromo_typ
{
    //the binary bit string is held in a std::string
  string    bits;  

    float     fitness;

    chromo_typ(): bits(""), fitness(0.0f){};
    chromo_typ(string …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm visual-studio genetic-algorithm

3
推荐指数
1
解决办法
1万
查看次数

矩阵上的垃圾,索引和唯一(如何保持矩阵格式)

在8x8矩阵上使用此方法:

>> [junk,index] = unique(data,'first');        %# Capture the index, ignore junk
>> data(sort(index))                           %# Index data with the sorted index
Run Code Online (Sandbox Code Playgroud)

以64x1格式输出格式(如果未找到重复)或如果找到重复,则输出nx1.

我的问题是如何在没有排序的情况下保留矩阵格式?

我需要它来检查重复的唯一(行)而不是唯一的单元格.并删除重复的行但保留格式(不要排列/排序).

sorting matlab unique matrix duplicates

3
推荐指数
1
解决办法
1826
查看次数

天真的分类器matlab

当在matlab中测试天真分类器时,即使我在相同的样本数据上进行了训练和测试,我得到了不同的结果,我想知道我的代码是否正确以及是否有人可以帮助解释为什么这样做?

%% dimensionality reduction 
columns = 6
[U,S,V]=svds(fulldata,columns);

%% randomly select dataset
rows = 1000;
columns = 6;

%# pick random rows
indX = randperm( size(fulldata,1) );
indX = indX(1:rows)';

%# pick random columns
%indY = randperm( size(fulldata,2) );
indY = indY(1:columns);

%# filter data
data = U(indX,indY);

%% apply normalization method to every cell
data = zscore(data);

%create a training set the same as datasample
training_data = data;

%match the class labels to the corresponding rows
target_class = classlabels(indX,:) …
Run Code Online (Sandbox Code Playgroud)

matlab classification machine-learning probability naivebayes

3
推荐指数
1
解决办法
1085
查看次数

在mvc中显示url slug而不是id

我有一个博客应用程序,用户可以创建帖子,我使用实体框架从数据库创建模型。在帖子中我有一个条目UrlSlug

但是,当我检查帖子的详细信息时:

控制器:

    public ActionResult Details(int id = 0)
    {
        Post post = db.Posts.Find(id);
        if (post == null)
        {
            return HttpNotFound();
        }
        return View(post);
    }
Run Code Online (Sandbox Code Playgroud)

id它返回一个末尾带有以下内容的 url :http://localhost:52202/Post/Details/1

我尝试返回 post.UrlSlug (引发错误)以及更改我的 RouteConfig.cs 文件来使用urlslugid它确实显示 urlslug,但由于控制器而无法找到页面)。如何更改此设置以便显示 urlslug 而不是 Post Table Id

路由配置.cs

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
Run Code Online (Sandbox Code Playgroud)

看法:

@for (int i …
Run Code Online (Sandbox Code Playgroud)

c# sql linq asp.net-mvc entity-framework

3
推荐指数
1
解决办法
3659
查看次数

Invalidcastexception JsonConvert.DeserializeObject

我收到一个无效的强制转换异常,指出指定的强制转换无效。在这一行:

RootObject mountain = JsonConvert.DeserializeObject<RootObject>(json1);
Run Code Online (Sandbox Code Playgroud)

文档来看,这应该没问题?我可以看到控制台输出正常吗?

响应:[{“Height_ft”:2999.0,“Height_m”:914.0,“ID”:“c1”,“纬度”:57.588007,“经度”:-5.5233564,“名称”:“Beinn Dearg”,“湿度”: 0.81,“snowCover”:4.99,“温度”:63.0}]

        Spinner spinner = (Spinner)sender;
        string urlmountain = "http://removed.azurewebsites.net/api/Mountains?name=";
        JsonValue json1 = FetchMountain(urlmountain+string.Format("{0}", spinner.GetItemAtPosition(e.Position)));
        //below.................................
        RootObject mountain = JsonConvert.DeserializeObject<RootObject>(json1); //this line
        string toast = mountain.Name;
        Toast.MakeText(this, toast, ToastLength.Long).Show();

    private JsonValue FetchMountain(string urlmountain)
    {
        // Create an HTTP web request using the URL:
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(urlmountain));
        request.ContentType = "application/json";
        request.Method = "GET";

        // Send the request to the server and wait for the response:
        using (WebResponse response = request.GetResponse()) …
Run Code Online (Sandbox Code Playgroud)

c# json json.net xamarin

3
推荐指数
1
解决办法
2036
查看次数

查询字符串到处理程序页面

如何创建从database.aspx 页面上的photopath 到handler.ashx 页面的查询字符串。

我希望处理程序页面能够获取此处包含的光路径字符串:

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string PhotoPath;

        GridViewRow row = GridView1.Rows[GridView1.SelectedIndex];

        PhotoPath = row.Cells[5].Text;
        PhotoPath = HttpUtility.UrlEncode(PhotoPath);

        HttpWebRequest request = (HttpWebRequest)
            WebRequest.Create(PhotoPath);
        HttpWebResponse response = (HttpWebResponse)
                request.GetResponse();
        Stream resStream = response.GetResponseStream();
        using (System.Drawing.Image img = System.Drawing.Image.FromStream(resStream))
        {
            img.Save("temp.jpg", ImageFormat.Jpeg);
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

然后在我的 GetImage.ashx 处理程序页面中检索它:

    public class GetImage : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            {
            string PhotoPath = System.Web.HttpContext.Current.Request.QueryString["PhotoPath"];
            PhotoPath = HttpUtility.UrlDecode(PhotoPath);
            FtpWebRequest request …
Run Code Online (Sandbox Code Playgroud)

c# asp.net http c#-4.0

2
推荐指数
1
解决办法
8244
查看次数

SQL语法错误

您好我认为我搞乱了我的sql语法,我似乎无法在asp.net中输出我的标签的名字和第二名

表用户有一个条目UserID = 1,我想将该条目的名称输出到我的标签:

 {
   OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};     
                                           Server=localhost; 
                                           Database=gymwebsite; 
                                           User=a; 
                                           Password=b;");
   cn.Open();

   OdbcCommand cmd = new OdbcCommand("SELECT (FirstName, SecondName) 
                                        FROM User 
                                       WHERE UserID = 1", cn);
   OdbcDataReader reader = cmd.ExecuteReader();

   while (reader.Read()) {
     Name.Text = (reader[1].ToString());
   }
}
Run Code Online (Sandbox Code Playgroud)

c# mysql sql asp.net

2
推荐指数
1
解决办法
97
查看次数

关于会议的教学?

任何人都可以教我如何使用会话吗?我有一个登录页面,它引用名为User的mysql db表,其中包括UserID ="variable number",用户名和密码.我希望能够将userid存储在会话中,以便我在登录时可以在用户配置文件中调用它.

这是怎么做到的?任何相关的编码和特定编码的放置都会有所帮助,因为我根本就没有把它拿起来.它是在(.cs文件)背后的代码中还是在aspx页面的html中保存?或两者以及如何?会话如何跨多个内部页面工作(一旦登录,您可以浏览多个与您自己的配置文件相关的页面)

    using System.Data.Odbc; 
    partial class login : System.Web.UI.Page 
    {        
    protected void   Login1_Authenticate(object sender, System.Web.UI.WebControls.AuthenticateEventArgs e)     
    {         
    OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=mydb; User=root;Password=;");         
cn.Open();
         OdbcCommand cmd = new OdbcCommand("Select * from login where username=? and password=?", cn);          
    //Add parameters to get the username and password            
    cmd.Parameters.Add("@username", OdbcType.VarChar);   
      cmd.Parameters["@username"].Value = this.Login1.UserName;

        cmd.Parameters.Add("@password", OdbcType.VarChar);  
       cmd.Parameters["@password"].Value = this.Login1.Password;  

        OdbcDataReader dr = default(OdbcDataReader);        
 // Initialise a reader to read the rows from the login table.   

  // If row …
Run Code Online (Sandbox Code Playgroud)

html c# asp.net

2
推荐指数
1
解决办法
130
查看次数

传递到字典中的模型项是视图模型类型,但需要通用IEnum

我的应用程序发生了灾难性的事情.每个细节页面都开始说:

传递到字典中的模型项的类型为'MyBlogger.Models.PostViewModel',但此字典需要类型为'System.Collections.Generic.IEnumerable`1 [MyBlogger.Models.Post]'的模型项.

它很好,一分钟,然后它开始这样做,每个单独的详细信息页面正在做一些字典类型的变化.

我被导航到是页面http://localhost:52202/Post/MainDetails/test-upload,http://localhost:52202/Post/Details/qwdqwdw等等等等

例如,第一个链接的控制器操作是:

namespace MyBlogger.Controllers
{
    public class PostController : Controller
    {
        private BlogEntities db = new BlogEntities();
        //public Tag tags = new Tag();
        //
        // GET: /Post/
        [Authorize]
        public ActionResult Index()
        {
            Dictionary<int, string> postImages = new Dictionary<int, string>();
            var posts = db.Posts.Where(p => p.BlogUserEmail == User.Identity.Name).Include(p => p.BlogUser).Include(p => p.Category);
            foreach (var item in posts)
            {
                byte[] buffer = item.Picture;
                postImages.Add(item.Id, Convert.ToBase64String(buffer));
            }
            ViewBag.Images = postImages;
            return View(posts.ToList());
        }
        //
        // …
Run Code Online (Sandbox Code Playgroud)

c# linq asp.net-mvc dictionary razor

2
推荐指数
1
解决办法
7977
查看次数