Click here to Skip to main content
15,883,705 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: What's so bad about webforms? Pin
jkirkerx18-Nov-19 16:07
professionaljkirkerx18-Nov-19 16:07 
GeneralRe: What's so bad about webforms? Pin
Eddy Vluggen19-Nov-19 2:47
professionalEddy Vluggen19-Nov-19 2:47 
GeneralRe: What's so bad about webforms? Pin
F-ES Sitecore18-Nov-19 23:18
professionalF-ES Sitecore18-Nov-19 23:18 
GeneralRe: What's so bad about webforms? Pin
Richard Deeming19-Nov-19 1:21
mveRichard Deeming19-Nov-19 1:21 
GeneralRe: What's so bad about webforms? Pin
F-ES Sitecore19-Nov-19 1:35
professionalF-ES Sitecore19-Nov-19 1:35 
GeneralRe: What's so bad about webforms? Pin
jkirkerx19-Nov-19 12:59
professionaljkirkerx19-Nov-19 12:59 
GeneralRe: What's so bad about webforms? Pin
F-ES Sitecore19-Nov-19 23:04
professionalF-ES Sitecore19-Nov-19 23:04 
GeneralRe: What's so bad about webforms? Pin
jkirkerx20-Nov-19 10:43
professionaljkirkerx20-Nov-19 10:43 
GeneralRe: What's so bad about webforms? Pin
DerekT-P20-Nov-19 1:22
professionalDerekT-P20-Nov-19 1:22 
GeneralRe: What's so bad about webforms? Pin
DerekT-P19-Nov-19 0:23
professionalDerekT-P19-Nov-19 0:23 
AnswerRe: What's so bad about webforms? Pin
F-ES Sitecore18-Nov-19 23:30
professionalF-ES Sitecore18-Nov-19 23:30 
AnswerRe: What's so bad about webforms? Pin
A_Griffin20-Nov-19 5:57
A_Griffin20-Nov-19 5:57 
GeneralRe: What's so bad about webforms? Pin
DerekT-P20-Nov-19 9:05
professionalDerekT-P20-Nov-19 9:05 
AnswerRe: What's so bad about webforms? Pin
Steve Naidamast24-Nov-19 6:53
professionalSteve Naidamast24-Nov-19 6:53 
GeneralRe: What's so bad about webforms? Pin
DerekT-P24-Nov-19 9:18
professionalDerekT-P24-Nov-19 9:18 
GeneralRe: What's so bad about webforms? Pin
Steve Naidamast25-Nov-19 4:30
professionalSteve Naidamast25-Nov-19 4:30 
QuestionFacing Issues while reading an excel file and inserting it's rows to a my sql tabble. Working fine in local machine but giving error after deployement Pin
Member 1465772316-Nov-19 3:23
Member 1465772316-Nov-19 3:23 
AnswerRe: Facing Issues while reading an excel file and inserting it's rows to a my sql tabble. Working fine in local machine but giving error after deployement Pin
phil.o16-Nov-19 4:08
professionalphil.o16-Nov-19 4:08 
GeneralRe: Facing Issues while reading an excel file and inserting it's rows to a my sql tabble. Working fine in local machine but giving error after deployement Pin
Member 1465772317-Nov-19 7:29
Member 1465772317-Nov-19 7:29 
GeneralRe: Facing Issues while reading an excel file and inserting it's rows to a my sql tabble. Working fine in local machine but giving error after deployement Pin
phil.o17-Nov-19 9:26
professionalphil.o17-Nov-19 9:26 
QuestionChange datatable from column to row and bind it to gridview Pin
Anand Solomon14-Nov-19 5:19
Anand Solomon14-Nov-19 5:19 
QuestionAccessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
Member 1115418813-Nov-19 18:34
Member 1115418813-Nov-19 18:34 
AnswerRe: Accessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
F-ES Sitecore13-Nov-19 23:23
professionalF-ES Sitecore13-Nov-19 23:23 
If you use the MasterType directive it will let you use strongly-typed master pages. If your master page is;

C#
using System.Web.UI;

namespace WebApplication1
{
    public partial class SiteMaster : MasterPage
    {
        public string SayHello()
        {
            return "Hello";
        }
    }
}


Add the MasterType directive to the top of your content page

HTML
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%@ MasterType TypeName="WebApplication1.SiteMaster" %>


In your page you can now access the "SayHello" function on your master page

C#
protected void Page_Load(object sender, EventArgs e)
{
    string text = Master.SayHello();
}


If you don't want to use the MasterType you can still acccess the master page code but you have to cast yourself

C#
var master = (SiteMaster) Master;
string text = master.SayHello();


If you have code in the master page that you need to access from non-page classes then the master page is the wrong place for that code. Put it in its own class rather than the master page.
GeneralRe: Accessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
Member 1115418814-Nov-19 0:17
Member 1115418814-Nov-19 0:17 
GeneralRe: Accessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
Richard Deeming14-Nov-19 1:25
mveRichard Deeming14-Nov-19 1:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.