질문이 업데이트되었습니다.ASP.NET JavaScript 함수 호출 코드 숨김
참조 : html로 링크를 클릭은 "일반 추가"때 http://www.startuppirates.org/blog/gritter/
이 제대로 작동 팔로우 그렇게 관련의 .js와 .CSS가 작동 통지를 보여줍니다.
HTML 링크
<a href="#" id="add-regular">Add regular notification</a>
자바 스크립트
<script type="text/javascript">
$('#add-regular').click(function() {
var unique_id = $.gritter.add({
// (string | mandatory) the heading of the notification
title: 'This is a regular notice!',
// (string | mandatory) the text inside the notification
text: 'This will fade out after a certain amount of time.',
// (string | optional) the image to display on the left
image: '/content/gritter/images/success.png',
// (bool | optional) if you want it to fade out on its own or just sit there
sticky: false,
// (int | optional) the time you want it to be alive for before fading out
time: '',
class_name: 'gritter-info'
});
return false;
});
</script>
내가 매개 변수로 함수에 JS 위에 수정 한, 나는 코드 숨김 (ASP에서 알림을 표시하는 호출하려고 해요 .net/web-forms)하지만 작동하지 않습니다!
Codebehind가
Page.ClientScript.RegisterStartupScript(Me.GetType(), "return", "stickyalert('Property Upload', 'property data uploaded successfully', 0, 'success');", True)
자바 스크립트
<script type="text/javascript">
function stickyalert(title, text, sticky, success) {
var unique_id = $.gritter.add({
// (string | mandatory) the heading of the notification
title: title,
// (string | mandatory) the text inside the notification
text: text,
// (string | optional) the image to display on the left
image: '/content/gritter/images/success.png',
// (bool | optional) if you want it to fade out on its own or just sit there
sticky: sticky,
// (int | optional) the time you want it to be alive for before fading out
time: '5000',
// (string | optional) the class name you want to apply to that specific message
class_name: 'gritter-info'
});
return false;
}
</script>
이 항목은 ASP.NET 페이지입니까? 그렇다면 Web Forms 또는 MVC를 사용하고 있습니까? –
Web Forms, thanks –
웹 응용 프로그램 작동 방식에 대한 이해를 수정해야합니다. 서버 측 코드가 실행될 때 위의 기능이 정의되고 실행될 수있는 사용자 브라우저에서 수십만 킬로미터 떨어져 있습니다. 모든 서버 측 코드는 브라우저 (전체 페이지, 페이지 또는 데이터의 일부)에 응답을 보내고 자바 스크립트가 브라우저에서 실행되기를 기대할 수 있습니다. – Igor