var obj = document.getElementByIdx_x(”testSelect”); //定位id
var index = obj.selectedIndex; // 选中索引
var text = obj.options[index].text; // 选中文本
var value = obj.options[index].value; // 选中值
jQuery中获得选中select值
第一种方式
$('#testSelect option:selected').text();//选中的文本
$('#testSelect option:selected') .val();//选中的值
$("#testSelect ").get(0).selectedIndex;//索引
第二种方式
$("#tesetSelect").find("option:selected").text();//选中的文本
…….val();
…….get(0).selectedIndex;
1. 不带任何提示关闭窗口的js代码
<a href="javascript:window.opener=null;window.open('','_self');window.close();">关闭</a>
2.自定义提示关闭
<script language="javascript">
// 这个脚本是 ie6和ie7 通用的脚本
function custom_close(){
if
(confirm("您确定要关闭本页吗?")){
window.opener=null;
window.open('','_self');
window.close();
}
else{}
}
</script>
<input id="btnClose" type="button" value="关闭本页" onClick="custom_close()" />
3.关闭当前页面:
<a href="javascript:window.opener=null;window.close();">关闭</a>如果是按钮则:
Response.Write("<script language=\"javascript\">window.opener=null;window.close();</script>");
C# int与string转化
1、int-->string
1 int a = 15;
2 string s1 = a.ToString();
3 string s2 = Convert.ToString(a);
2、string -->int
1 string s = "18";
2 int a1 = int.Parse(s);
3 int a2;
4 int.TryParse(s, out a2);
5 int a3 = Convert.ToInt32(s);
c# string 转 GUID
1 /* 2 * string TO guid 3 */ 4 private static bool ToGuid(string str) 5 { 6 Guid gv = new Guid(); 7 try 8 { 9 gv = new Guid(str); 10 } 11 catch (Exception) 12 { 13 14 } 15 if (gv != Guid.Empty) 16 { 17 return true; 18 } 19 else 20 { 21 return false; 22 } 23 }
2.match匹配
1 /* 2 * string TO guid 3 */ 4 private static bool ToGuid(string str) 5 { 6 Match m = Regex.Match(str,@"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$",RegexOptions.IgnoreCase); 7 Guid gv = new Guid(); 8 if (m.Success) 9 { 10 gv = new Guid(str); 11 } 12 if (gv != Guid.Empty) 13 { 14 return true; 15 } 16 else 17 { 18 return false; 19 } 20 }
使按钮不可点击
设置disabled属性为true即为不可用状态。JS: document.getElementByIdx("btn").disabled=true;
jquery $("#btn").attr("disabled", true);
- var uuid = Guid.NewGuid().ToString(); // 9af7f46a-ea52-4aa3-b8c3-9fd484c2af12
- var uuidN = Guid.NewGuid().ToString("N"); // e0a953c3ee6040eaa9fae2b667060e09
- var uuidD = Guid.NewGuid().ToString("D"); // 9af7f46a-ea52-4aa3-b8c3-9fd484c2af12
- var uuidB = Guid.NewGuid().ToString("B"); // {734fd453-a4f8-4c5d-9c98-3fe2d7079760}
- var uuidP = Guid.NewGuid().ToString("P"); // (ade24d16-db0f-40af-8794-1e08e2040df3)
- var uuidX = Guid.NewGuid().ToString("X"); // {0x3fa412e3,0x8356,0x428f,{0xaa,0x34,0xb7,0x40,0xda,0xaf,0x45,0x6f}}