小编Dun*_*nes的帖子

如何在Asp.net中回发后维护标签的价值?

在asp.net页面中,我需要知道如何通过单击html按钮来保持特定标签赋值的值.回发完成后.

详细代码:

 <table>
        <tr>
            <td><asp:Label ID="lbl1" runat="server" ClientIDMode="Static">Before Changing</asp:Label></td>

            <td><asp:Label id="lbl2" runat="server" ClientIDMode="Static"></asp:Label></td>

            <td><asp:TextBox ID="txtbox" runat="server"></asp:TextBox></td>

</tr>

        <tr>
            <td><asp:Button ID="btnasp" runat="server"  Text="ASP Button" Height="50px" Width="150px" OnClick="btnasp_Click"/></td>

            <td><input type="button" id="btnhtml" value="HTML Button" onclick="showlabel()"  style="height:50px; width:150px"/></td>
        </tr>

    </table>
Run Code Online (Sandbox Code Playgroud)

脚本

 <script type="text/javascript">
    function showlabel() {
        $('#lbl1').text("After Changing");

        }
</script>
Run Code Online (Sandbox Code Playgroud)

cs代码

   protected void btnasp_Click(object sender, EventArgs e)
    {

        txtbox.Text = lbl1.Text;
    }
Run Code Online (Sandbox Code Playgroud)

产量

在此输入图像描述

如果我单击HTML按钮,更改前的标签文本将更改为更改后.然后在更改值显示在文本框中后单击ASP按钮.

这是在不在隐藏字段中添加值而不使用服务器控件到html按钮的情况下完成的.这怎么可能?

c# asp.net postback

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

确定字符串是否为回文的最快方法

如果字符串是回文(字符串可以是带有大写或小写字母,空格等的命题),我需要一种能够以最快的执行时间进行验证的算法.所有这些都在Java中.我有一个样本:

bool isPalindrome(string s) {
    int n = s.length();
    s = s.toLowerCase();
    for (int i = 0; i < (n / 2) + 1; ++i) {
        if (s.charAt(i) != s.charAt(n - i - 1)) {
            return false;
        }
    }
    return true;
}
Run Code Online (Sandbox Code Playgroud)

我使用.toLowerCase()函数将字符串转换为小写字母,但我不知道它对执行时间有多大影响.

而且我不知道如何以有效的方式解决标点符号和单词之间的空格问题.

java performance palindrome

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

如何限制访问Arraylist并禁止更改?

我如何限制Arraylist的访问(检索/插入/更新/删除)并禁止更改其值?

我在接受采访时遇到过这个问题.

java arraylist immutability

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

编辑代码示例以指定 DES 密钥值

我有一个使用 DES 的工作代码示例(见下文),但我想指定要使用的关键数据。如何编辑代码示例来执行此操作?

import java.security.InvalidKeyException;  
import java.security.NoSuchAlgorithmException;    
import javax.crypto.BadPaddingException;  
import javax.crypto.Cipher;  
import javax.crypto.IllegalBlockSizeException;  
import javax.crypto.KeyGenerator;  
import javax.crypto.NoSuchPaddingException;  
import javax.crypto.SecretKey;

public class DESEncryptionDecryption {

private static Cipher encryptCipher;  
private static Cipher decryptCipher; 
public static void main(String[] args) {  
try {
KeyGenerator keygenerator = KeyGenerator.getInstance("DES");  
SecretKey secretKey = keygenerator.generateKey();  

encryptCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");  
encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey);  
byte[] encryptedData = encryptData("Classified Information!");  

decryptCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");  
decryptCipher.init(Cipher.DECRYPT_MODE, secretKey);  
decryptData(encryptedData);
}}}
Run Code Online (Sandbox Code Playgroud)

java security encryption des key

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

在没有编译错误的情况下更改对方法的访问

有人可以演示一个简单程序的示例,其中在工作程序中将一个方法的访问权限从私有更改为公共将不会导致编译错误,但只会导致程序行为不同吗?

此外,何时添加新的私有方法会导致编译错误或导致程序行为不同?

java private public access-modifiers

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

我应该使用 KeyGenerator 还是 SecretKeyFactory?

我需要在 Java 中实现 DES,我看到有时使用KeyGenerator有时使用生成密钥的示例SecretKeyFactory,两者似乎都有效。

问题是哪种方法更好还是它们相同?如果它们相同,为什么要采用两种方法?

java cryptography

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

DatatypeConverter是线程安全的吗?

特别是,该方法是javax.xml.bind.DatatypeConverter.parseBase64Binary(String)线程安全的吗?

java base64 jaxp thread-safety

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

断言某些参数化向量会在JUnit中抛出异常?

我想知道如何为特定的异常断言编写测试?

例如(我的测试数据容器):

@Parameters(name = "{index}: {0} > {1} > {2} > {3} > {4}")
public static Iterable<Object[]> data() {
  return Arrays.asList(new Object[][] {
    {"1200", new byte[] {0x4B0}, "1200", 16, 2},
    {"10", new byte[] {0x0A}, "10", 8, 1},
    {"13544k0", new byte[] {0x0A}, "1200", 8, 1},  <== assert thrown exception
    {"132111115516", new byte[] {0x0A}, "1200", 8, 1},<== assert thrown exception
  });
}
Run Code Online (Sandbox Code Playgroud)

是否可以使用这样的容器数据来断言异常,或者我需要在具体的测试方法中建模情况?

java junit unit-testing exception parameterized

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

如何从供应商那里获取导入包?

我正在检查供应商的功能.这是很棒的安装所有包,但我无法设置go命令在供应商包中找到它们.

go run src/main.go

src/main.go:8:2: cannot find package "github.com/valyala/fasthttp" in any of:
   /home/joaonrb/.software/lib/go/go1.7/src/github.com/valyala/fasthttp (from $GOROOT)
   /home/joaonrb/.projects/go-blog/src/github.com/valyala/fasthttp (from $GOPATH)
Run Code Online (Sandbox Code Playgroud)

安装了Fasthttp /home/joaonrb/.projects/go-blog/src/vendor/github.com/valyala/fasthttp,我使用的版本是1.7,我的GOPATH是/home/joaonrb/.projects/go-blog

go glide-golang

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

如何在Material UI网格项目中将项目水平居中?

如何在Material UI Grid项内居中放置元素?这是我的React应用程序的片段:

<Grid container>
  <Grid item xs={4}>
    // Unrelated stuff here
  </Grid>
  <Grid item xs={4}>
    // How do I centre these items?
    <IconButton className={classes.menuButton} color="inherit">
      <EditIcon/>
    </IconButton>
    <IconButton className={classes.menuButton} color="inherit">
      <CheckBoxIcon/>
    </IconButton>
  </Grid>
  <Grid item xs={4}>
    // Unrelated stuff here
  </Grid>
</Grid>
Run Code Online (Sandbox Code Playgroud)

我试过申请alignContentjustifyalignItems(父<Grid item>),但没有成功。

我以为这很简单,但是我没找到关于网格项目内部居中项目的任何信息。

css reactjs material-ui

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