Skip to content

Commit eb9e5ef

Browse files
authored
docs(common): update code snippet tabs
1 parent 9b48987 commit eb9e5ef

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

knowledge-base/common-use-cookies-to-help-execute-custom-javascript-after-a-file-starts-to-download.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ Usually, when a file is being downloaded, the server clears the response and res
2020

2121
To workaround this, we can add a cookie to the response on the server and look for it in the client-side. To achieve that, before sending the request to the server, we can start checking for this cookie on a given interval of time until the cookie is present. Once the cookie is present, we will know that the server responded with the file and we can do our custom logic and clear the cookie.
2222

23+
>caption RadButton Markup
2324
24-
```ASP.NET
25+
````ASP.NET
2526
<telerik:RadButton runat="server" ID="RadButton1" OnClientClicking="OnClientClicking" OnClick="RadButton1_Click" Text="Download File" AutoPostBack="true" />
26-
```
27+
````
2728

28-
```JavaScript
29+
>caption OnClientClicking client-side event
30+
31+
````JavaScript
2932
function OnClientClicking(sender, args) {
3033
pollingAPI.startPolling(function (cookieMessage) {
3134
alert(cookieMessage)
3235
}, 200);
3336
}
34-
```
37+
````
3538

36-
```JavaScript
39+
````JavaScript
3740
var cookieAPI = (function (undefined) {
3841
function clearCookie(cookieName) {
3942
setCookie(cookieName, "", new Date());
@@ -70,9 +73,11 @@ var cookieAPI = (function (undefined) {
7073
clearCookie: clearCookie
7174
}
7275
})();
73-
```
76+
````
77+
78+
>caption The Polling (JavaScript function)
7479
75-
```JavaScript
80+
````JavaScript
7681
var pollingAPI = (function (cookieAPI) {
7782
function startPolling(callbackFunction, pollingInterval) {
7883
var cookieName = "file-download";
@@ -99,9 +104,11 @@ var pollingAPI = (function (cookieAPI) {
99104
}
100105

101106
})(cookieAPI);
102-
```
107+
````
108+
109+
>caption Button's Click event
103110
104-
```C#
111+
````C#
105112
protected void RadButton1_Click(object sender, EventArgs e)
106113
{
107114
Response.Clear();
@@ -124,8 +131,8 @@ protected void RadButton1_Click(object sender, EventArgs e)
124131

125132
Response.End();
126133
}
127-
```
128-
```VB
134+
````
135+
````VB
129136
Protected Sub RadButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
130137
Response.Clear()
131138

@@ -145,10 +152,8 @@ Protected Sub RadButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
145152
myCookie.Value = "The file started downloading!"
146153
HttpContext.Current.Response.Cookies.Add(myCookie)
147154

148-
Response.[End]()
155+
Response.End()
149156
End Sub
150-
```
151-
152-
153-
157+
````
158+
154159

0 commit comments

Comments
 (0)