小编BRB*_*RBT的帖子

ASP.Net验证摘要导致页面跳转到顶部

我有一个简单的表单,其中包含一些必需的字段验证器和一个验证摘要控件.当我提交表单时,客户端验证将使表单跳转到页面顶部.如果我删除验证摘要,页面不会移动.

下面是一个简单的例子:

<asp:TextBox ID="test" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="testrequired" runat="server" ControlToValidate="test">*</asp:RequiredFieldValidator>
<asp:ValidationSummary ID="summary" runat="server" />
<asp:Button ID="submit" runat="server" Text="submit" />
Run Code Online (Sandbox Code Playgroud)

我已经尝试设置SetFocusOnError="true"必需的字段验证器和MaintainScrollPositionOnPostback="true"咯咯笑 - 即使这不是一个回发 - 没有任何运气.这个问题有一个已知的解决方案吗?

编辑:

我在WebResource.axd生成的js中发现了问题.似乎在ValidationSummaryOnSubmit()功能中归结为一行.

line 534: window.scrollTo(0,0);
Run Code Online (Sandbox Code Playgroud)

有关如何删除或绕过此的任何想法?

EDIT2:

暂时快速解决:

  • EnableClientScript="false"为所有验证控件设置(禁用客户端验证)
  • MaintainScrollPositionOnPostback="true"在Page指令中设置

仍然希望客户端解决方案......

EDIT3:

似乎更好的解决方法是覆盖window.scrollTo()函数,以便在验证脚本调用时不执行任何操作:

<script type="text/javascript">
    window.scrollTo = function() { }
</script>
Run Code Online (Sandbox Code Playgroud)

在页面上的任何位置添加上述内容会使客户端验证,但在window.scrollTo()整个页面中禁用该方法

asp.net validation

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

Powershell列出了一系列日期之间的日期.

我正在写一个脚本PowerShell,我需要知道一系列日期之间的日期.

该脚本用于自动化报告.假设有一堆记录的数据,但数据只在工作日收集,没有周末,也没有假期.我FTP并收集记录的最后15代.

使用脚本,我打开了最新的报告实例Excel.打开工作簿后,我读取了一个包含日期的单元格,该日期将确定上次运行报表的时间.(今天的数据要到明天才能获得,所以它总是落后一天.)

当我没有那个日期时,我Get-Date用来获取当前日期.我需要知道当前日期和我从Excel读入的日期之间的日期.之后,我将需要查看是否有任何日期在假期,或周末是否已经下降.

$excelDate = $excel.Cells.Item(1489, 1).Value()
$currentDate = Get-Date 
Run Code Online (Sandbox Code Playgroud)

让我们说吧 $excelDate = "03/07/2014"

$currentDate = "03/14/2014"

我想得到的是2014年8月3日,03/09/2014,3/10/2014,3/11/2014,03/12/2014,03/13/2014.

一旦我有了这些日期,我可以检查一下他们是否有假期,以及他们是否已经度过了一个周末.

如果他们度假,我可以减去1天(如果报告中的最后一天在星期五下降,则为2天......我仍在试图弄清楚我将如何做到这一点.),并使用一个switchget-content在我开始解析并将其放入之前的正确数据Excel.

所以像这样:

switch($daysMissed)    
        {                                                       
           1  {Write-Host "The Report is currently up to date!!"                       }   
           2  {$data = get-content C:\Users\$userName\Desktop\Report\data\data.txt  }  
           3  {$data = get-content C:\Users\$userName\Desktop\Report\data\data2.txt } 
           4  {$data = get-content C:\Users\$userName\Desktop\Report\data\data3.txt }
           5  {$data = get-content C:\Users\$userName\Desktop\Report\data\data4.txt }
           6  {$data = get-content C:\Users\$userName\Desktop\Report\data\data5.txt }
           7  {$data = …
Run Code Online (Sandbox Code Playgroud)

excel powershell date

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

当我尝试删除图像 PHP 时 unlink() 不起作用

我正在尝试使用该函数从目录中删除图像unlink()

if (file_exists($oldPicture)) {
    unlink($oldPicture);
    echo 'Deleted old image';
} 
else {
    echo 'Image file does not exist';
}
Run Code Online (Sandbox Code Playgroud)

$oldPicture的值为../images/50/56/picture.jpg

以下代码块运行时没有任何错误,但是当我检查目录时图像仍然存在。

我在这里做错了什么吗?

谢谢

php unlink

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

Powershell比较对象格式输出

这是我写的脚本:

function Compare {

    $file1 = Read-Host "Please enter the path of the first file you would like to compare"
    $file2 = Read-Host "Please enter the path of the second file you would like to compare"

    $outFile = Read-Host "Please enter the path to where you would like your output file."

    Try{
        $compareOne = Get-Content $file1
        $comparetwo = Get-Content $file2
    } 
    Catch{
        Write-Host "The path you entered is either invalid or the file does not exist. "    
    }

    Write-Host "Beginning …
Run Code Online (Sandbox Code Playgroud)

powershell output compareobject

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

如果数组中的元素与值匹配,则将其删除

我正在解析文本文件中的一堆数据。我得到的数据Get-Content。然后我遍历的每一行$data。在空格上分割每一行,并将这些值加载到数组中。

然后,我遍历$string数组中的每个数组。

如果$string匹配特定值,我想将其从数组中删除。

$index.Delete(), $index.Remove() 不起作用,这就是我所拥有的。

$data = Get-Content "C:\Users\$userName\Desktop\test-data.txt"

foreach($row in $data){
    if($row)
    {
        [Array]$index = $row.Split(" ")

        $i = 0 
        foreach($string in $index){

            Write-Host $string 

            if($string -eq "value1" -or $string -eq "value2" -or $string -eq "value3")
            {
                $index.Delete() //This does not work. 
            }
        }
Run Code Online (Sandbox Code Playgroud)

我也尝试过类似的方法,但是根本没有用。

for($i -eq $index.length; $i -le 0; $i++)
{
    Write-Host $index[$i]  #this would hit once then give me an error saying the value is null 

    if($index[$i] …
Run Code Online (Sandbox Code Playgroud)

arrays powershell

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

如何提高MySQL查询执行时间

我遇到了一个问题,在我的查询中,执行需要大约14秒,我需要它更快.

无论如何我可以优化吗?

SELECT *
FROM large_table
WHERE (
INET_ATON( 'record number' )
BETWEEN INET_ATON( starting_number )
AND INET_ATON( ending_number )
)
LIMIT 0 , 30
Run Code Online (Sandbox Code Playgroud)

mysql

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

这里不允许'void'类型(java)错误

这是我的代码:

public void start()
{
  //If the gas tank and oil have more than nothing, and the transmission is in gear park, then the car can start
  if((gasTank.getGasLevel() > 0) && (engine.getOilLevel() > 0) && (transmission.gearPark()))
  {
    engine.startEngine();
    System.out.println("Engine is now on");
  }
  else
  {
    System.out.println("Please make sure your car is in proper gear, engine has oil and gas.");
  }
}
Run Code Online (Sandbox Code Playgroud)

我一直在收到'void' type not allowed here错误.我不是想要返回任何东西所以我知道我不需要int,Boolean,double等.

我究竟做错了什么?

java types void

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

HTML表单PHP帖子没有点击

不知道为什么我遇到这个问题,我正在制作一个允许用户更新数据的编辑表单.

我有一个HTML表单,如下所示:

<form enctype="multipart/form-data" method="post" action="updatefacility.php">
    <label for="fac_number">Facility Number: </label>
    <input type="text" id="fac_number" name="fac_number" value="<?php if (!empty($facNum)) echo $facNum; ?>" /><br />
    <label for="fac_name">Facility Name: </label>
    <input type="text" id="fac_name" name="fac_name" value="<?php if (!empty($facName)) echo $facName; ?>" /><br />
    <label for="fac_address">Address: </label>
    <input type="text" id="fac_address" name="fac_address" value="<?php if (!empty($facAddress)) echo $facAddress; ?>" /><br />
    <input type="button" value="Update" name="update">
</form>
Run Code Online (Sandbox Code Playgroud)

当我点击我的按钮时,我应该点击updatefacility.php这样:

$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);        
if (!$dbc) {
    die("Connection failed: " . mysqli_connect_error());
}

 if (isset($_POST['update'])) {

     echo …
Run Code Online (Sandbox Code Playgroud)

html php

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

标签 统计

powershell ×3

php ×2

arrays ×1

asp.net ×1

compareobject ×1

date ×1

excel ×1

html ×1

java ×1

mysql ×1

output ×1

types ×1

unlink ×1

validation ×1

void ×1