Skip to content

feat: ClientScript Phase 2 — PostBack + ScriptManager shims#116

Closed
csharpfritz wants to merge 7 commits intodevfrom
feature/clientscript-phase2
Closed

feat: ClientScript Phase 2 — PostBack + ScriptManager shims#116
csharpfritz wants to merge 7 commits intodevfrom
feature/clientscript-phase2

Conversation

@csharpfritz
Copy link
Copy Markdown
Owner

ClientScript Phase 2 — PostBack + ScriptManager Shims

Target: open against upstream/dev (FritzAndFriends) — opened here on origin due to token permissions. Please retarget or open upstream PR manually.

Phase 1 (FritzAndFriends#530) delivered RegisterStartupScript, RegisterClientScriptBlock, and RegisterClientScriptInclude as zero-rewrite shims. Phase 2 extends the surface area to cover postback events and ScriptManager patterns.

What's New

🔧 Runtime Shims

  • GetPostBackEventReference(control, arg) — returns working __doPostBack('id','arg') JS string
  • GetPostBackClientHyperlink(control, arg) — returns javascript:__doPostBack(...) URL
  • GetCallbackEventReference(...) — returns JS callback bridge string
  • ScriptManagerShim with GetCurrent(page) static factory
  • PostBackEventArgs — event args for postback handling
  • bwfc-postback.js__doPostBack JS bridge via DotNetObjectReference

🔧 CLI Transform Updates

  • GetPostBackEventReference calls preserved (shim-compatible, no more TODOs)
  • ScriptManager.GetCurrent(Page)ScriptManager.GetCurrent(this)
  • 353 CLI tests passing

📝 Documentation

  • Updated ClientScriptMigrationGuide.md, BWFC022.md, BWFC024.md

🎆 Demo + Tests

  • PostBackDemo page (3 sections), 35 new unit tests, 3 Playwright tests

Zero-Rewrite Example

// Web Forms → Blazor with BWFC (same code!)
string script = ClientScript.GetPostBackEventReference(myButton, "save");
ScriptManager sm = ScriptManager.GetCurrent(this);

csharpfritz and others added 7 commits April 6, 2026 21:54
- GetPostBackEventReference now documented as zero-rewrite (shim support)
- ScriptManager.GetCurrent documented with ScriptManagerShim pattern
- GetCallbackEventReference bridge pattern documented (new section 5)
- Updated coverage summary to show full Phase 2 support
- Updated BWFC022 analyzer to reference Phase 2 shim path
- Updated BWFC024 analyzer to reference ScriptManager.GetCurrent() Phase 2 support
- Renumbered sections 6-11 to accommodate new callback section

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…se 2)

- GetPostBackEventReference calls now preserved (shim-compatible)
- ScriptManager.GetCurrent(Page)  ScriptManager.GetCurrent(this)
- Removed TODO markers  shims handle these patterns at runtime
- Added/updated CLI test assertions for Phase 2 patterns

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- GetPostBackEventReference() returns working __doPostBack JS string
- GetPostBackClientHyperlink() returns javascript: URL
- GetCallbackEventReference() returns working JS callback bridge
- Created bwfc-postback.js with __doPostBack and callback interop
- PostBackEventArgs for event handling
- ScriptManagerShim with GetCurrent() factory pattern
- WebFormsPageBase postback target registration via JS interop
- Registered ScriptManagerShim in DI

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- PostBack button trigger test
- PostBack hyperlink click test
- ScriptManager startup script registration test
- CI-friendly timeouts (30s) learned from Phase 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- PostBackDemo/Index.razor with GetPostBackEventReference, hyperlink, and ScriptManager sections
- Stable element IDs for Playwright integration testing (postback-button, postback-link, scriptmanager-target, etc.)
- Added to ComponentCatalog.cs under Migration Helpers category
- Added to ComponentList.razor under Migration Helpers section
- Inherits WebFormsPageBase for PostBack event, ClientScript access, and ScriptManagerShim.GetCurrent(this)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- GetPostBackEventReference output format and escaping tests
- GetPostBackClientHyperlink javascript: prefix tests
- GetCallbackEventReference bridge string tests
- ScriptManagerShim.GetCurrent factory + delegation tests
- PostBackEventArgs construction tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
await _jsRuntime.InvokeVoidAsync(
"__bwfc.unregisterPostBackTarget", _postBackTargetId);
}
catch (JSDisconnectedException) { }
"__bwfc.unregisterPostBackTarget", _postBackTargetId);
}
catch (JSDisconnectedException) { }
catch (ObjectDisposedException) { }
}
catch (JSDisconnectedException) { }
catch (ObjectDisposedException) { }
catch (InvalidOperationException) { }
@csharpfritz
Copy link
Copy Markdown
Owner Author

Closing reopening against upstream (FritzAndFriends)

@csharpfritz csharpfritz closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants