=IF(COUNTIF(A:A,B2)>0,"相同","不相同") <=B表姓名值是否出現在A表中?
2017年11月5日 星期日
2017年10月20日 星期五
[ASP.NET] vb.net call javascript function
vb.net call javascript function
一、
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:openUserAppSetting();return false;" />
二、
<asp:Button ID="but_save" runat="server" Text="提交變更" class="btn btn-primary" OnClientClick="return openUserAppSetting();"/>
<asp:Button id="Button2" runat="server" Text="XD" OnClientClick="closeUserAppSetting();" OnClick="Button2_Click" UseSubmitBehavior="false" />
OnClientClick會在onclick之前執行
三、
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "", "showDisplay()", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "showDisplay();", True)
<script type="text/javascript">
function openUserAppSetting() {
$('#userAppSetting').skygqbox();
}
function closeUserAppSetting() {
$('#userAppSetting').hide();
}
</script>
HTML/javascript call vb function
[ HTML ]
<td onclick="callServersideFunction()">日期</td>
[ javascript ]
//call vb function
function callServersideFunction() {
var someValueToPass = name;
__doPostBack('CustomPostBack', someValueToPass);
}
[ vb ]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Insure that the __doPostBack() JavaScript method is created...
Me.ClientScript.GetPostBackEventReference(Me, String.Empty)
'If IsPostBack = False Then
Dim eventTarget As String = ""
Dim eventArgument As String = ""
If Request("__EVENTTARGET") Is Nothing Then
eventTarget = String.Empty
Else
eventTarget = Request("__EVENTTARGET")
End If
If Request("__EVENTARGUMENT") Is Nothing Then
eventArgument = String.Empty
Else
eventArgument = Request("__EVENTARGUMENT")
End If
If eventTarget = "CustomPostBack" Then
Dim valuePassed As String = eventArgument
' there call function....
End If
' End If
End Sub
一、
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:openUserAppSetting();return false;" />
二、
<asp:Button ID="but_save" runat="server" Text="提交變更" class="btn btn-primary" OnClientClick="return openUserAppSetting();"/>
<asp:Button id="Button2" runat="server" Text="XD" OnClientClick="closeUserAppSetting();" OnClick="Button2_Click" UseSubmitBehavior="false" />
OnClientClick會在onclick之前執行
三、
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "", "showDisplay()", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "showDisplay();", True)
<script type="text/javascript">
function openUserAppSetting() {
$('#userAppSetting').skygqbox();
}
function closeUserAppSetting() {
$('#userAppSetting').hide();
}
</script>
HTML/javascript call vb function
[ HTML ]
<td onclick="callServersideFunction()">日期</td>
[ javascript ]
//call vb function
function callServersideFunction() {
var someValueToPass = name;
__doPostBack('CustomPostBack', someValueToPass);
}
[ vb ]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Insure that the __doPostBack() JavaScript method is created...
Me.ClientScript.GetPostBackEventReference(Me, String.Empty)
'If IsPostBack = False Then
Dim eventTarget As String = ""
Dim eventArgument As String = ""
If Request("__EVENTTARGET") Is Nothing Then
eventTarget = String.Empty
Else
eventTarget = Request("__EVENTTARGET")
End If
If Request("__EVENTARGUMENT") Is Nothing Then
eventArgument = String.Empty
Else
eventArgument = Request("__EVENTARGUMENT")
End If
If eventTarget = "CustomPostBack" Then
Dim valuePassed As String = eventArgument
' there call function....
End If
' End If
End Sub
[ASP.NET]判斷要寫入的資料是否與資料表相同,若不相同才進行更新
Function IsRowModified_u(ByVal r As GridViewRow) As Boolean
Dim Curr_OrgID As String
Dim Curr_HomoID As String
Dim Curr_LineNum As String
Dim lv_RadioButtonList As String
Dim lv_HAZARDOUS_VALUE As String
Dim lv_REASON As String
Curr_OrgID = CType(r.FindControl("lb_org_id"), Label).Text 'Convert.ToInt32(GridView1.DataKeys(0).Value)
Curr_HomoID = CType(r.FindControl("lb_HOMOGENOUS_MAT_ID"), Label).Text
Curr_LineNum = CType(r.FindControl("lb_LINE_NUM"), Label).Text
lv_RadioButtonList = CType(r.FindControl("RadioButtonList1"), RadioButtonList).Text
lv_HAZARDOUS_VALUE = CType(r.FindControl("tb_HAZARDOUS_VALUE"), TextBox).Text
lv_REASON = CType(r.FindControl("tb_REASON"), TextBox).Text
Dim row As DataRow = originalDataTable_u.[Select]([String].Format("org_id = {0} and HOMOGENOUS_MAT_ID={1} and line_num={2}", Curr_OrgID, Curr_HomoID, Curr_LineNum))(0)
If lv_RadioButtonList.Equals(row("INCLUDE_YN").ToString()) = True And _
lv_HAZARDOUS_VALUE.Equals(row("HAZARDOUS_VALUE").ToString()) = True And _
lv_REASON.Equals(row("REASON").ToString()) = True Then
Return True
Else
Return False
End If
'Return False
End Function
Dim Curr_OrgID As String
Dim Curr_HomoID As String
Dim Curr_LineNum As String
Dim lv_RadioButtonList As String
Dim lv_HAZARDOUS_VALUE As String
Dim lv_REASON As String
Curr_OrgID = CType(r.FindControl("lb_org_id"), Label).Text 'Convert.ToInt32(GridView1.DataKeys(0).Value)
Curr_HomoID = CType(r.FindControl("lb_HOMOGENOUS_MAT_ID"), Label).Text
Curr_LineNum = CType(r.FindControl("lb_LINE_NUM"), Label).Text
lv_RadioButtonList = CType(r.FindControl("RadioButtonList1"), RadioButtonList).Text
lv_HAZARDOUS_VALUE = CType(r.FindControl("tb_HAZARDOUS_VALUE"), TextBox).Text
lv_REASON = CType(r.FindControl("tb_REASON"), TextBox).Text
Dim row As DataRow = originalDataTable_u.[Select]([String].Format("org_id = {0} and HOMOGENOUS_MAT_ID={1} and line_num={2}", Curr_OrgID, Curr_HomoID, Curr_LineNum))(0)
If lv_RadioButtonList.Equals(row("INCLUDE_YN").ToString()) = True And _
lv_HAZARDOUS_VALUE.Equals(row("HAZARDOUS_VALUE").ToString()) = True And _
lv_REASON.Equals(row("REASON").ToString()) = True Then
Return True
Else
Return False
End If
'Return False
End Function
2017年8月29日 星期二
[ASP.NET] 從ASP.NET後台取得HTML的標籤
從ASP.NET後台取得HTML的標籤
方法一、
僅取得HTML標籤值(唯讀)。
<input type="button" name="mybut" value="按鈕" />
Request.Form("mybut")
方法二、
控制HTNL標籤。
在HTML標籤上加讓runat="server" id="myIcon",在ASP後台就可以取得控制。
<i runat="server" id="myIcon" class="icon-repeat"></i>
針對類別進行控制:
myIcon.Attributes.Add("class", openRotationImg)
針對樣式進行控制:
myIcon.Style.Add("color", "red")
方法一、
僅取得HTML標籤值(唯讀)。
<input type="button" name="mybut" value="按鈕" />
Request.Form("mybut")
方法二、
控制HTNL標籤。
在HTML標籤上加讓runat="server" id="myIcon",在ASP後台就可以取得控制。
<i runat="server" id="myIcon" class="icon-repeat"></i>
針對類別進行控制:
myIcon.Attributes.Add("class", openRotationImg)
針對樣式進行控制:
myIcon.Style.Add("color", "red")
[ASP.NET] 使用MaintainScrollPositionOnPostback="true" 在Chrome則會失效
在ASPNET中使用MaintainScrollPositionOnPostback="true",來達到Postback時頁面不要回到頂部。
在IE可以正常運行,但在Chrome則會失效。
解決方法:
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" MaintainScrollPositionOnPostback="true" CodeFile="Default8.aspx.vb" Inherits="Default8" %>
在IE可以正常運行,但在Chrome則會失效。
解決方法:
<asp:HiddenField runat="server" ID="hfPosition" Value="" />
<script type="text/javascript">
$(function () {
var f = $("#<%=hfPosition.ClientID%>");
window.onload = function () {
var position = parseInt(f.val());
if (!isNaN(position)) {
$(window).scrollTop(position);
}
};
window.onscroll = function () {
var position = $(window).scrollTop();
f.val(position);
};
});
</script>
[JavaScript] 設定與取得Cookie值
轉載至:https://blog.aidec.tw/post/javascript-set-get-cookie
設定cookie
function setCookie(cookieName, cookieValue, exdays) { if (document.cookie.indexOf(cookieName) >= 0) { var expD = new Date(); expD.setTime(expD.getTime() + (-1*24*60*60*1000)); var uexpires = "expires=" +expD.toUTCString(); document.cookie = cookieName + "=" + cookieValue + "; " + uexpires; } var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires=" +d.toUTCString(); document.cookie = cookieName + "=" + cookieValue + "; " + expires; } |
使用方法:
setCookie('自訂名稱','cookie值','天數');
舉例:
setCookie('myName','aidec','365');
將會設定一個名為myName的
cookie
,其cookie
值為aidec,生命週期為365天
註:若已經有設定相同名稱的
cookie
值,此function
將會自動覆蓋掉舊的值。代碼說明:
此部分解說此函數原理,方便讓人自行修改。
/*第一段*/ //判斷是否已經有相同的cookie值。有的話,使舊的cookie過期 if (document.cookie.indexOf(cookieName) >= 0) { var expD = new Date(); expD.setTime(expD.getTime() + (-1*24*60*60*1000)); var uexpires = "expires=" +expD.toUTCString(); document.cookie = cookieName + "=" + cookieValue + "; " + uexpires; } /*第二段*/ //設定cookie值 var d = new Date(); //可以自行修改此段,將過期週期設為符合需求的格式 d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires=" +d.toUTCString(); document.cookie = cookieName + "=" + cookieValue + "; " + expires; |
讀取cookie
function getCookie(cookieName) { var name = cookieName + "=" ; var ca = document.cookie.split( ';' ); for ( var i=0; i<ca.length; i++) { var c = ca[i]; while (c.charAt(0)== ' ' ) c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length,c.length); } return "" ; } |
使用方法
getCookie('自訂的cookie名稱');
舉例:
以剛剛我們設定名為myName的
cookie
為範例getCookie('myName'); //可得到 aidec
這樣就簡單完成用javascript設定和讀取cookie值了~~若假如想要能移除某項cookie值的話,我們可以提取setCookie當中的第一段在寫成另一個function來用,這樣就可以達成刪除某一cookie啦
訂閱:
文章 (Atom)