小编SLa*_*aks的帖子

VB流行颜色选择器


我有一个关于 VB 事件处理程序和颜色选择器的问题。
现在我有一个标签,我希望当用户单击它时,它会弹出一个颜色选择器对话框,让用户更改标签的背景颜色。
不知道如何实现这一点,谁能给我一个方向?

谢谢

vb.net event-handling winforms

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

Silverlight HTTP POST

我只是想在http://www.test.com/test.asp?test1=3上发表一篇http帖子.这是我一直在尝试使用的代码:

    private void pif_test_conn()
    {


        Uri url = new Uri("http://www.test.com/test.asp?test1=3", UriKind.Absolute);



        if (httpResult == true)
        {


            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.ContentType = "application/x-www-form-urlencoded";
            request.Method = "POST";
           request.BeginGetResponse(new AsyncCallback(ReadCallback), request); 

        }



        return ;
    }


   private void ReadCallback(IAsyncResult asynchronousResult)
    {


        HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;


        HttpWebResponse response =  (HttpWebResponse)request.EndGetResponse(asynchronousResult);

        using (StreamReader streamReader1 =  new StreamReader(response.GetResponseStream()))
        {

            string resultString = streamReader1.ReadToEnd();

             MessageBox.Show("Using HttpWebRequest: " + resultString, "Found", MessageBoxButton.OK);             
        }

    }
Run Code Online (Sandbox Code Playgroud)

当我执行此代码时,我的程序会触发Application_UnhandledException事件.不确定我做错了什么.

silverlight

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

检查列表<MyObject>是否已在集合中

通常我用哈希表:

if(!myHash.Contains(someId))
{
   // insert to hash
}
Run Code Online (Sandbox Code Playgroud)

如果我有一个List,我该怎么检查使用contains?

现在我只是创建一个用户ID的哈希表,并检查它,但有没有办法只使用List?

c# collections

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

返回分层xml的节点级别

在树视图中,您可以检索项目的级别.我试图用给定的输入作为对象来完成同样的事情.

我将用于此示例的XML数据类似于以下内容

<?xml version="1.0" encoding="utf-8" ?>
<Testing>
  <Numbers>
    <Number val="1">
      <Number val="1.1">
        <Number val="1.1.1">
          <Number val="1.1.2" />
          <Number val="1.1.3" />
          <Number val="1.1.4" />
        </Number>   
      </Number>
      <Number val="1.2" />
      <Number val="1.3" />
      <Number val="1.4" />
    </Number>
    <Number val="2" />
    <Number val="3" />
    <Number val="4" />
  </Numbers>
  <Numbers>
    <Number val="5" />
    <Number val="6" />
    <Number val="7" />
    <Number val="8" />
  </Numbers>
</Testing>
Run Code Online (Sandbox Code Playgroud)

这个踢我的屁股!

c# hierarchical-data

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

jQuery:查找特定的HREF链接

基本上,我们的想法是找出文档的当前位置,并更改要更改的链接类(导航手风琴).到目前为止,我在下面有这个,如果pageURL(变量)是实际的链接,但我不想创建一个可能的链接的完整列表,因此$(位置).att('href');

$(document).ready(function() {
    var pageURL = $(location).attr('href');
    $('a[href=pageURL]').attr('class', 'active');
});
Run Code Online (Sandbox Code Playgroud)

任何人的任何帮助将不胜感激

提前致谢

jquery href

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

如何通过C#代码运行powercfg的功能?

如何通过c#代码运行powercfg的功能?
例如,我想运行它,为Set关闭显示:never

powercfg -CHANGE -monitor -timeout -ac 0 
Run Code Online (Sandbox Code Playgroud)

.net c# powercfg

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

以编程方式在C#中将文本添加到剪贴板

有没有办法以C#(3.5)或javascript编程方式将文本添加到剪贴板?客户端机器类型是否有所作为?

编辑:对不起,忘了提到我正在使用asp.net.

javascript c# asp.net

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

无法将"System.Data.DataRowView"类型的对象强制转换为"System.Data.DataRow"类型

我将发布自我找到解决方案后出现的错误的答案.

我在asp.net中收到错误:无法将'System.Data.DataRowView'类型的对象强制转换为'System.Data.DataRow'类型

// Old line
// rpOutils.DataSource = ds.Tables[0].Select("rnco_lang = '" + ddlLang.SelectedValue + "'");
// rpOutils.DataSource = ds; // New line that caused the error. I just wanted to pass a DataSet
rpOutils.DataSource = ds.Tables[0].Select(); // New line with the solution.
rpOutils.DataBind();

protected void rpOutils_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRow row = (DataRow)e.Item.DataItem; // I received the System.InvalidCastException
Run Code Online (Sandbox Code Playgroud)

...

数据集返回了一个DataRowView,导致问题的行是DataRow.

我搜索了解决方案并没有找到,所以我找到了它并发布了我的解决方案.谢谢.

c# asp.net ado.net compiler-errors

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

不能在泛型方法中隐式转换类型错误

我的通用方法有问题:

    public ReadOnlyObservableCollection<T> GetReadOnlyObjectsFromDB<T>() 
    {
        var typeofT = typeof(T);
        if (typeofT.GetType() == typeof(Customer))
        {
            return new ReadOnlyObservableCollection<Customer>
                  (new ObservableCollection<Customer>(dbContext.Customers));
        }
        else if(typeofT.GetType() == typeof(Article))
        {
            return new ReadOnlyObservableCollection<Article>
                  (new ObservableCollection<Article>(dbContext.Articles));
        }
    }
Run Code Online (Sandbox Code Playgroud)

我总是得到这个错误:

Cannot implicitly convert type 'System.Collections.ObjectModel.ReadOnlyObservableCollection<Customer>' to 'System.Collections.ObjectModel.ReadOnlyObservableCollection<T>'

和文章相同.我认为用这种方法清楚我想要的但我不知道我的错误是什么......

感谢您的帮助和新年快乐!

c# generics

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

Passport Node.js CORS错误

我已经尝试了一百万种方法让护照与我的申请一起工作无济于事.每次尝试登录每个提供商(Facebook,谷歌,Twitter,微软)都会导致如下错误:

XMLHttpRequest cannot load https://www.google.com/accounts/o8/ud?openid.mode=checkid_setup&openid.ns=h…2F%2Ftest.sl%2Fauth%2Fgoogle%2Freturn&openid.realm=http%3A%2F%2Ftest.sl%2F. 
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://test.sl' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)

我的应用程序并不复杂,这里是我的服务器代码的摘要.

var express = require('express');
var ppGoogle = require('passport-google-oauth').OAuth2Strategy;
var app = express();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/public'));
//There's more config

app.listen(7230);

app.get('/auth/google', passport.authenticate('google'));
app.get('/auth/google/return', passport.authenticate('google', {
   successRedirect: '/main',
   failureRedirect: '/login'
}));

passport.use(new ppGoogle({
    clientID: '',
    clientSecret: '',
    callbackURL: 'http://test.sl/auth/google/return'
},
function (accessToken, refreshToken, profile, done)
{
    console.log('done');
}));
Run Code Online (Sandbox Code Playgroud)

谁知道解决方案?这件事让我抓狂.

javascript cors express passport.js

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