Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello every one,
I am new to asp.net all wanted to know if we can create a partial view in webforms, kindly paste the links or code in the answer.

Best Regards,
Thank You.

Here is the code and i have to put partial view in "Book Meeting Time" column by clicking on "Click Me".
ASP.NET
<pre><asp:TemplateField HeaderText="Book Meeting Time">
                    <ItemTemplate>
                           <a href="">Click Here</a>
                   </ItemTemplate>
                </asp:TemplateField>


What I have tried:

ASP.NET
<pre><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BookMeetingTime.aspx.cs" Inherits="MeetingTime.BookMeetingTime" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
<pre><center>
        Search : <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
        <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" />
            <hr />
        <asp:GridView ID="GridView1" runat="server" ShowHeaderWhenEmpty="true" EmptyDataText="No Records Found.">
            <columns>
                <%--<asp:BoundField DataField="BookMeetingTime" HeaderText="Book Meeting Time"/>--%>
                <asp:TemplateField HeaderText="Book Meeting Time">
                    <ItemTemplate>
                           <a href="">Click Here</a>
                   </ItemTemplate>
                </asp:TemplateField>
            </columns>
        </asp:GridView>
            </center>
    </div>
    </form>
Posted
Updated 13-Dec-19 1:02am
Comments
F-ES Sitecore 13-Dec-19 4:49am    
The best webforms equivalent of partial views are probably user controls.

https://www.guru99.com/asp-net-controls-webforms.html

 
Share this answer
 
The way that I learned this was through the usage of User Controls, which will be a file pair (markup page + code behind); that can be called in a web-forms page.
There is some more work that needs to be done than using partials within the MVC paradigm, but as it is quite mature there is plenty of documentation and tutorials available for it

Some Tutorials:
ASP.NET Web Forms Tutorial: User Controls Examples[^]
Creating User Control in ASP.Net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900