|
1 | 1 | # Blazor.WebForm.Components |
2 | | - ASP.NET Web Forms System.Web.UI.WebControls Razor Components For Blazor WebAssembly. |
| 2 | + ASP.NET Web Forms System.Web.UI.WebControls Razor Components For Blazor WebAssembly, Blazor Hybrid, Blazor Server. |
3 | 3 |
|
4 | 4 | Demo: <https://blazorwebformdemo.github.io/> |
5 | 5 |
|
@@ -129,3 +129,41 @@ Demo: <https://blazorwebformdemo.github.io/> |
129 | 129 | <td>RequiredFieldValidator</td><td></td> |
130 | 130 | </tr> |
131 | 131 | </table> |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | +### Blazor Server |
| 137 | + |
| 138 | +Add CircuitHandler service to Program.cs |
| 139 | + |
| 140 | +<pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;">builder.Services.AddScoped<CircuitHandler, ScriptManagerCircuitHandler>();</code></pre> |
| 141 | + |
| 142 | + |
| 143 | +<pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;">using Microsoft.AspNetCore.Components.Server.Circuits; |
| 144 | +using System.Web.Hosting; |
| 145 | + |
| 146 | +namespace Server |
| 147 | +{ |
| 148 | + public class ScriptManagerCircuitHandler : CircuitHandler |
| 149 | + { |
| 150 | + private readonly IServiceProvider _serviceProvider; |
| 151 | + |
| 152 | + public ScriptManagerCircuitHandler(IServiceProvider serviceProvider) |
| 153 | + { |
| 154 | + _serviceProvider = serviceProvider; |
| 155 | + } |
| 156 | + |
| 157 | + public override Task OnCircuitOpenedAsync(Circuit circuit, CancellationToken cancellationToken) |
| 158 | + { |
| 159 | + ScriptManagerHost.AddScoped(_serviceProvider); |
| 160 | + return base.OnCircuitOpenedAsync(circuit, cancellationToken); |
| 161 | + } |
| 162 | + |
| 163 | + public override Task OnCircuitClosedAsync(Circuit circuit, CancellationToken cancellationToken) |
| 164 | + { |
| 165 | + ScriptManagerHost.RemoveScoped(_serviceProvider); |
| 166 | + return base.OnCircuitClosedAsync(circuit, cancellationToken); |
| 167 | + } |
| 168 | + } |
| 169 | +}</code></pre> |
0 commit comments