小编med*_*eda的帖子

如何在发布项目时交换连接字符串?

我可以看到该Web.config文件包含两个文件:

-web.Debug.config
-web.Release.config
Run Code Online (Sandbox Code Playgroud)

在这个配置文件中有以下注释:

在下面的示例中,仅当"匹配"定位器找到具有值"MyDB"的属性"名称"时,"SetAttributes"转换才会将"connectionString"的值更改为使用"ReleaseSQLServer".

<connectionStrings>
  <add name="MyDB" 
    connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)

什么是"Match" locator?我已经有一个连接字符串了,Web.config那我该怎么设置呢?主web.config文件应该包含生产连接字符串还是反过来?我正在寻找那些做过类似事情的人的挚爱

asp.net iis web-config publishing visual-studio-2010

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

如何使用textfieldParser编辑CSV文件?

我写了一个小函数,它逐行使用textField读取csv文件,将其编辑为特定字段,然后将其写回CSV文件.

这是代码:

private void button2_Click(object sender, EventArgs e)
    {
        String path = @"C:\file.csv";
        String dpath = @"C:\file_processed.csv";
        List<String> lines = new List<String>();

        if (File.Exists(path))
        {
            using (TextFieldParser parser = new TextFieldParser(path))
            {
                String line;

                parser.HasFieldsEnclosedInQuotes = true;
                parser.Delimiters = new string[] { "," };



                while ((line = parser.ReadLine()) != null)
                {
                      string[] parts = parser.ReadFields();

                     if (parts == null)
                     {
                         break;
                     }                   

                          if ((parts[12] != "") && (parts[12] != "0"))
                          {

                              parts[12] = parts[12].Substring(0, 3);
                              //MessageBox.Show(parts[12]);
                          }

                    lines.Add(line);
                }
            } …
Run Code Online (Sandbox Code Playgroud)

c# csv parsing textfield

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

如何将监听器添加到切换按钮?

我试图向Switch添加一个监听器,但由于某种原因它不会收听检查事件.

CompoundButton.OnCheckedChangeListener在我的活动上实现 了这样的:

public class MyActivity extends Activity 
           implements CompoundButton.OnCheckedChangeListener 
Run Code Online (Sandbox Code Playgroud)

这是我的代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_layout);

    newOrSavedSwitch = (Switch)  findViewById(R.id.new_or_saved_switch);        
}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   Toast.makeText(this, "Monitored switch is " + (isChecked ? "on" : "off"),
           Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)

吐司没有显示,我也没有看到logcat中的错误.

java android oncheckedchanged switch-statement

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

如何在本地使用jQuery ui-icon?

我正在尝试使用jQuery Modal对话框,它的工作原理如下:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
Run Code Online (Sandbox Code Playgroud)

但是当我在本地保存它们时,缺少关闭图标:

<link rel="stylesheet" href="Styles/jquery-ui.css" /> 
<script src="Styles/jquery.min.js" type="text/javascript"></script>
<script src="Styles/jquery-ui.min.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

当我检查html时,我可以看到:

<span class="ui-icon ui-icon-closethick" unselectable="on">close</span>
Run Code Online (Sandbox Code Playgroud)

我在jquery-ui.css中也找到了ui-icon-closethick,但我找不到一种方法来保存本地图标

我在这里找到了Icon .

html css jquery modal-dialog

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

如果记录不存在,我怎么才能插入记录?

我目前正在制作一个简单的IP禁止脚本,我正处于将IP地址插入数据库的阶段.我为此创建的HTML表单包含两个字段; IP地址和原因:

<td width="70%"><h4>Ban New IP:</h4>(Enter IP to be banned)</td>
    <td width="30%">
    <form method="post" action="">
     IP Address: <input type="text" id="ip" name="ip" autocomplete="off" maxlength="15" /><br /><br />
     Enter Reason: <input type="text" id="reason" name="reason" autocomplete="off" maxlength="255" /><br /><br />
     <input type="submit" id="submit" name="submit" value="Ban IP" /><br /><br />
Run Code Online (Sandbox Code Playgroud)

我的数据库包含一个标题为banned_ips三列的表id, ip and reason.我创建的插入语句完美无缺,但是我想查看IP是否已经存在.目前它只会插入IP,即使有一个匹配它.这是我目前的查询:

<?php

if ($_POST) {
    if ($_POST['ip'] != '') {
        if (strlen($_POST['ip']) <= 15) {
            $ip = $_POST['ip'];

            $ip_clean = htmlentities($ip);

            if (isset($ip_clean)) {
                // SQL insert …
Run Code Online (Sandbox Code Playgroud)

php mysql sql

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

需要帮助在MVC中对齐单选按钮

我很难使用RadioButtonFor在MVC 4模板中左侧对齐单选按钮.

由于某种原因,他们被放置在中间,abd它只发生在下面的单选按钮是一张图片:

我试图浮动div但它没有用.

我还尝试将css类添加到单选按钮帮助程序,但我收到函数RadioButtonFor的重载错误

我甚至试着把它放进一张桌子里

请指教,这是我的代码

<div class="editor-field"  >
<table>
<tr>
    <td>
           @Html.RadioButtonFor(model => model.isChildTakingMedicine, true, new { @onchange = "showTextBox()" }) YES<br />
    </td>
</tr>
<tr><td>
            @Html.RadioButtonFor(model => model.isChildTakingMedicine, false, new { @onchange = "showTextBox()" }) NO
            @Html.ValidationMessageFor(model => model.isChildTakingMedicine)
     </td> 
</tr>
</table>  
</div>
Run Code Online (Sandbox Code Playgroud)

alignment radiobuttonfor asp.net-mvc-4

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

为什么 MediaRecorder 会延迟开始录制?

我在我的 android 应用程序中实现了一个功能,它使用mediaRecorder. 它工作正常,但由于某些原因跳过了录制的第一秒。

我使用了开发人员文档中完全相同的代码,所以我不明白为什么会这样做。

我寻找这个问题的答案,我发现很少有人有同样的问题,但没有真正的解决方案。

这是我的研究:

我有一个 LG 设备,不确定它是否可能是硬件问题。我也知道一些替代方法mediaRecorder,我只是想知道是否有人找到了解决此问题的方法。

java audio android audio-recording mediarecorder

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

需要帮助阅读目标c中的plist文件

我一直在尝试从plist文件读取数据。这就是它的结构

|term|detail(string)|
Run Code Online (Sandbox Code Playgroud)

我的财产:

@property (nonatomic, strong) NSDictionary *terms;
@property (nonatomic, strong) NSArray *termKeys;//this is just a array to keep track
@property (nonatomic, strong) NSString *detail;
Run Code Online (Sandbox Code Playgroud)

这是我访问cellForRowAtIndexPath中的详细信息的方式

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [[UITableViewCell alloc]
                             initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];

    NSString *currentTermsName = [termKeys objectAtIndex :[indexPath row]];
                                  [[cell textLabel] setText:currentTermsName];
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;


    detail = [terms objectForKey:[termKeys objectAtIndex:indexPath.row]];

    NSLog(@" bombs %@",terms[@"Bomb Threats"]);
    return cell;

}
Run Code Online (Sandbox Code Playgroud)

鉴于didload我有

 - (void)viewDidLoad
    {
        [super viewDidLoad];


        NSString *myfile = [[NSBundle mainBundle]
                            pathForResource:@"terms" ofType:@"plist"];
        terms = [[NSDictionary …
Run Code Online (Sandbox Code Playgroud)

objective-c plist uitableview

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

PHP编码JSON(二维数组)

我正在查询返回字段的表(message_type&percentage).我使用PHP来编码json数据,这是我的工作方式

$json = array();
while ($row = odbc_fetch_array($rs)) {
  $json[][] = $row;
}
echo json_encode($json);
Run Code Online (Sandbox Code Playgroud)

输出:

[ [ { "message_type" : "bullying",
      "percentage" : "60"
    } ],
  [ { "message_type" : "cheating",
      "percentage" : " 14"
    } ],
  [ { "message_type" : "Stress",
      "percentage" : "16"
    } ],
  [ { "message_type" : "Gang",
      "percentage" : "7"
    } ]
]
Run Code Online (Sandbox Code Playgroud)

如您所见,json_encode函数正在添加花括号,引号和对象键名.

我想要的是只将json解析为二维数组,这是所需的输出:

[
  ["bullying", 60],
  ["harrassment", 9],
  ["cheating", 14],
  ["Stress", 16],
  ["Gang", 7]
]
Run Code Online (Sandbox Code Playgroud)

我也尝试手动编码,但我无法得到我需要的结果.

php arrays json

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

使用R.something的getSharedPreferences?

有这些线:

String app_name = "@string/app_name";
SharedPreferences sharedPreferences = getSharedPreferences(app_name, 0);
Run Code Online (Sandbox Code Playgroud)

我得到一个IllegalArgumentException:

File @ string/app_name.xml包含路径分隔符

如果我这样做:

SharedPreferences sharedPreferences = getSharedPreferences("MyAppName", 0);
Run Code Online (Sandbox Code Playgroud)

它运行正常,但如何在不对应用程序名称进行硬编码的情况下使用它?我不能使用R.string.app_name,因为那是一个int.

android sharedpreferences

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