TOP

[ASP.NET] 防止按鈕重覆點擊

防止按鈕重覆點擊

<asp:Button ID="btSubmit" runat="server"  UseSubmitBehavior="false"  />

C#
btSubmit.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btSubmit, null) + ";"); 

VB.Net
btSubmit.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btSubmit, Nothing) + ";")  

參考資料:
http://www.dotblogs.com.tw/joysdw12/archive/2011/11/22/58961.aspx
http://www.dotnetvishal.com/2013/01/disable-button-double-click-in-aspnet.html
http://www.dotblogs.com.tw/puma/archive/2008/03/16/1663.aspx
http://www.dotblogs.com.tw/sam19820611/archive/2010/04/14/14589.aspx
http://www.dotblogs.com.tw/joysdw12/archive/2011/11/22/58961.aspx
TOP

[ASP.NET] TextBox改為 MultiLine時MaxLength 無效問題

一般如果使用Textbox可以利用MaxLength 限制輸入的長度,但如果改為MultiLine時會發生MaxLength 無效問題。
<script type="text/javascript">
//檢查<TEXTAREA>的maxlength
function ismaxlength(obj){

  var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""

  if (obj.getAttribute && obj.value.length>mlength)

    obj.value=obj.value.substring(0,mlength)

}

</script


ASPX:

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
 TextBox1.Attributes.Add("maxlength", "200");

TextBox1.Attributes.Add("onkeyup", "return ismaxlength(this)");



CodeBehind:
TextBox1.Attributes.Add("maxlength", "200");

TextBox1.Attributes.Add("onkeyup", "return ismaxlength(this)");



參考資料:
http://yanchi-huang.blogspot.tw/2011/12/aspnet-textbox-multiline-maxlength-is.html

http://pramaire.pixnet.net/blog/post/22512127-textbox%E5%9C%A8textmode%3Dmultiline%E7%8B%80%E6%85%8B%E4%B8%8Bmaxlength%E7%9A%84%E5%AD%97%E6%95%B8%E9%99%90
TOP

[ASP.NET] FaceBook,Google+,Twitter及微博使用Share button時指定縮圖、名稱及簡介內容

FaceBook,Google+,Twitter使用Share button時指定縮圖、名稱及簡介內容

方法1.
<link rel="image_src" href="name.jpg" />

 方法2.
<HEAD runat="server">
<meta property="og:title" content="名稱,Facebook" />
<meta property="og:type" content="web-design" />
<meta property="og:url" content="www.yahoo.com.tw" />
<meta property="og:image" content="http://www.abcdef.com.tw/images/logo.jpg" />
</HEAD>

參考資料:
http://compilerok.blogspot.tw/2013/08/facebook.html
http://cloud.zoes.tw/index.php/web-design/33-fb
http://www.freegroup.org/2012/10/how-to-avoid-no-thumbnail-issue-on-facebook/
http://jimmyyen.blogspot.tw/2010/10/blogger-facebook-facebook-like-button.html
https://developers.google.com/+/web/snippet/
http://fundesigner.net/facebook-cache/

Google+ 在share butoon 已移除Descriptions

參考資料:
http://www.seoskeptic.com/google-quietly-removes-descriptions-from-snippets/

微博參考資料:
http://open.weibo.com/sharebutton
http://www.moke.tw/wordpress/note/307
http://open.weibo.com/wiki/Weibo_meta_tag

TOP

[ASP.NET] UpdatePanel無效或失靈,造成整頁Postback。

問題:UpdatePanel使用的元件及方式跟另外一台電腦都相同,但其中一台電腦一直發生UpdatePanel無效或失靈,造成整頁Postback,無法局佈Postback的狀況。


處理方式:
web.config裡面移除
<configuration>
    <system.web>
        <xhtmlConformance mode="Legacy" />
    </system.web>
</configuration>

web.config設置
將 <system.web> 下 <xhtmlConformance mode="Legacy"/> 移除,此段為web標準的設置,但宣告此語法會讓 ajax 加載相關 js 時只加載一部份,以至於 UpdatePanel 失效,故拿掉此段語法。

使用ASP.NET AJAX UpdatePanel 控件时,做整页 postback,而不仅是局部更新。
当你打开你的web.config文件,你会看到其中的 <xhtmlConformance/> 元素,象这样:
<configuration>
    <system.web>
        <xhtmlConformance mode="Legacy" />    </system.web>
</configuration>

參考資料:
http://www.cnblogs.com/wf225/archive/2007/07/11/813580.html

http://fishsses.pixnet.net/blog/post/52406822-%E4%BD%BF%E7%94%A8-updatepanel-%E5%AF%A6%E7%8F%BE-dropdownlist-%E4%B8%8D%E5%88%B7%E6%96%B0%E9%80%A3%E5%8B%95%EF%BC%8C%E5%8C%85

http://www.cnblogs.com/calmzeal/archive/2007/04/04/699983.html

http://www.haogongju.net/art/214636

http://www.debugease.com/aspdotnet/682418.html
TOP

[ASP.NET] Google+,FaceBook,Twitter Share Button


利用Onclick控制視窗開啟大小
<script type="text/javascript">
            function OpenWindow(Url, width, height) {
                retVal = window.open(Url, "", "width=" + width + ",height=" + height +",menubar=no,location=no,status=no,resizable=no,scrollbars=yes");
            }                                
</script>

asp.net HyperLink加圖片方式顯示,因為使用Onclick所以加上 style="cursor:pointer;" 當滑鼠移到圖片上時顯示「手指」圖式。

<asp:HyperLink ID="hplGoogleShare" runat="server" ImageUrl="~/images/share.png" Target="_blank" style="cursor:pointer;"></asp:HyperLink>
<asp:HyperLink ID="hplFbShare" runat="server" ImageUrl="~/images/share.png" Target="_blank" style="cursor:pointer;"></asp:HyperLink>
                        <asp:HyperLink ID="hplTwitterShare" runat="server" ImageUrl="~/images/share.png" Target="_blank" style="cursor:pointer;"></asp:HyperLink>

加上Attributes的onclick

 FBShareUrl = "https://www.facebook.com/sharer/sharer.php?u=http://www.abc.com"
 GoogleShareUrl = "https://plus.google.com/share?url=http://www.abc.com"

 hplFbShare.Attributes.Add("onclick", "javascript:OpenWindow('" & FBShareUrl & "','500','300');void(0);")

hplGoogleShare.Attributes.Add("onclick", "javascript:OpenWindow('" & GoogleShareUrl & "','620','400');void(0);")

hplTwitterShare.Attributes.Add("onclick", "javascript:OpenWindow('https://twitter.com/share','500','400');void(0);")


參考資料:
Twitter
https://dev.twitter.com/docs/tweet-button
https://about.twitter.com/resources/buttons#tweet

FaceBook
https://developers.facebook.com/docs/plugins/share-button

Google+
https://developers.google.com/+/web/share/?hl=zh-TW
http://stackoverflow.com/questions/6585722/use-custom-image-for-google1-button
http://www.google.com/intl/en/webmasters/+1/button/index.html?utm_source=b2cp1&utm_medium=link&utm_campaign=p1#customize-snippet