Skip to content

Commit 8e14978

Browse files
committed
2.2.0.1
1 parent e38131e commit 8e14978

5 files changed

Lines changed: 62 additions & 4 deletions

File tree

-90.6 KB
Binary file not shown.
91.2 KB
Binary file not shown.

Blazor.WebForm.Components/Base/ControlComponentBase.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,14 @@ protected void RequestRefresh(TemplateControl control)
401401

402402
protected virtual void OnSubmit(object sender, EventArgs e)
403403
{
404-
this.SendMessage("RequestLoadPostData", this.TemplateControl);
404+
if ((this.ClientScript as IPlatformClientScript).InProcess)
405+
{
406+
this.SendMessage("RequestLoadPostData", this.TemplateControl);
407+
}
408+
else
409+
{
410+
this.SendMessage("RequestLoadPostDataAsync", this.TemplateControl);
411+
}
405412
}
406413

407414
[MessageNotifyMethod]
@@ -417,6 +424,19 @@ protected void RequestLoadPostData(TemplateControl control)
417424
}
418425
}
419426

427+
[MessageNotifyMethod]
428+
protected async Task RequestLoadPostDataAsync(TemplateControl control)
429+
{
430+
if (_disposed || control != this.TemplateControl)
431+
{
432+
return;
433+
}
434+
if (this.Control is IPostBackDataHandler)
435+
{
436+
await this.LoadPostDataAsync(false);
437+
}
438+
}
439+
420440
public static implicit operator TControl(ControlComponentBase<TControl> component)
421441
{
422442
return component.Control;

Blazor.WebForm.Components/Blazor.WebForm.Components.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<SignAssembly>true</SignAssembly>
66
<AssemblyOriginatorKeyFile>Blazor.WebForm.Components.pfx</AssemblyOriginatorKeyFile>
7-
<Version>2.0.1.6</Version>
7+
<Version>2.2.0.1</Version>
88
<RootNamespace>asp</RootNamespace>
99
<Copyright>Jurio li</Copyright>
1010
<AssemblyName>Blazor.WebForm.Components</AssemblyName>
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="Applied" Version="1.2.1.6" />
20-
<PackageReference Include="Blazor.WebForm.UI" Version="2.0.1.6" />
20+
<PackageReference Include="Blazor.WebForm.UI" Version="2.2.0.1" />
2121
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.6" />
2222
</ItemGroup>
2323

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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.
33

44
Demo: <https://blazorwebformdemo.github.io/>
55

@@ -129,3 +129,41 @@ Demo: <https://blazorwebformdemo.github.io/>
129129
<td>RequiredFieldValidator</td><td></td>
130130
</tr>
131131
</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: &quot;Source Code Pro&quot;, 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: &quot;Source Code Pro&quot;, Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;">builder.Services.AddScoped&lt;CircuitHandler, ScriptManagerCircuitHandler&gt;();</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: &quot;Source Code Pro&quot;, 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: &quot;Source Code Pro&quot;, 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

Comments
 (0)