@RenderPage() If Div is Empty

I want to render a page using @RenderPage() if a specific div is empty (excluding whitespace). However, I don’t know how to go upon doing this.
I tried doing this:


@if (Request["#divid"].IsEmpty()){
   @RenderPage("pagepath.cshtml")
}

I thought maybe this might work like when requesting the the content of an input tag using the ‘name’ attribute, but it doesn’t.

If this would be better to do in Javascript then point me in the right direction.

Thanks. (Also, sorry if this is in the wrong forum, I thought since I’m using C# this might belong here.)

I don’t think you can make @RenderPage directives conditional but you might be able to do that for @RenderSection().