الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

بخصوص ال interaction مع ال master page من كلاس خاص

بدأه Mohannad Otaibi في 22 مارس 2010 · 26 رد · 2,436 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم جميعأً

أنا مبرمج جديد على ال ASP.net لكن لدي الخلفيات البرمجية الكافية للبدء بأمور صغيرة في ال ASP.net

حالياً أنا بصدد إنشاء Website project لإحتياجات العمل ولكن جميع خبراتي السابقة كانت على PHP, Java, C# فقط

طريقة ترتيب الصفحات والكلاسات من خلال الـ Visual Web Developer 2008 أعتقد لوحدها تحتاج إلى خبرة إضافية

المشكلة:

لدي Master Page ليجمع الأمور المشتركة بين جميع صفحات الموقع , وفي هذا الماستر بيج , وضعت خانات Label بداخل Div لعرض رسائل ال Error Message أو ال System Messages

هذا هو كود الليبل في الماستر بيج <asp:Label ID="testlabel" runat="server" Text="Test Value"></asp:Label>

طبعا الـ Content Page التي قمت بإنشاءها بإسم Default.aspx ستعرض محتوى الليبل الا وهو Test Value من ضمن ما يأتي من الماستر بيج

هدفي:

أريد هذه الصفحة Default.aspx عند بداية عملها في ال Page_Load مثلاً , تقوم بتغيير محتوى الليبل هذا إلى مثلاً Default Value

هذا الأمر بسيط وبالإمكان عمله من خلال ال code-behind الخاص ب default.aspx

المشكلة هي أني أريد عمل Function خاصة في ملف c# class خاص بداخل مجلد includes مثلاً وتعمل على جميع صفحات الموقع , بحيث يكون إسمها مثلاً setErrorMessage

ف الفكرة هي كيف إنك تتصل بالماستر بيج من خلال includes/systemMsg.cs

في الرد التالي سأضع محتوى بعض الملفات لتجربتي الحالية

#2

في محاولة لإنشاء Base Class كـ interface للـ Master Page بداخل مجلد includes , هذا ماحصل معي

MyMaster.Master

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="~/includes/MasterBase.cs" 
Inherits="BoTest.MyMaster" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>First Title</title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div> This is A test</div>
    <br />
        <asp:Label ID="TestLabel" runat="server" Text="Test Content Of Label"></asp:Label>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
        <br />
        <div> This is a footer test</div>
    </div>
    </form>
</body>
</html>

MyMaster.Master.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BoTest
{
    public partial class MyMaster : BoTest.includes.MasterBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BoTest.includes;

namespace BoTest
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterBase exa = new MasterBase();
            exa.LabelText = "Hello";
        }
    }
}

includes/MasterBase.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BoTest.includes
{
    public class MasterBase : MasterPage
    {
        protected Label TestLabel;
        public string LabelText
        {
            get { return TestLabel.Text; }
            set { TestLabel.Text = value; }
        }

    }
}

عند عمل Build

يطلع لي إيرور Exception

System.NullReferenceException was unhandled by user code
  Message="Object reference not set to an instance of an object."
  Source="BoTest"
  StackTrace:
       at BoTest.includes.MasterBase.set_LabelText(String value) in D:\Users\otaimf0n\Desktop\My Work\webpage\BoTest\BoTest\includes\MasterBase.cs:line 16
       at BoTest.Default.Page_Load(Object sender, EventArgs e) in D:\Users\otaimf0n\Desktop\My Work\webpage\BoTest\BoTest\Default.aspx.cs:line 16
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:
#3

This is not a good design at all. Don't ever write any business logic into the pages because this is prone to errors and not testable!

Instead use the following approach:

1 - Create an intermediate class which will be responsible to handle error messages


{

public static string ErrorMessage{get; set;}

}
public void static class ErrorMessagesManager

2 - In DefaultPage for example in the Page_Load or when the error happen just call the following code:

ErrorMessagesManager.ErrorMessage = "Error has been thrown";

3 - Then in MasterPage you can in Page_Load or whatever you want, use the following:

_errorLabel.Text = ErrorMessagesManager.ErrorMessage;

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#4
نور الإسلام كتب:

This is not a good design at all. Don't ever write any business logic into the pages because this is prone to errors and not testable!

Instead use the following approach:

1 - Create an intermediate class which will be responsible to handle error messages

{


public static string ErrorMessage{get; set;}


}

public void static class ErrorMessagesManager

2 - In DefaultPage for example in the Page_Load or when the error happen just call the following code:

ErrorMessagesManager.ErrorMessage = "Error has been thrown";

3 - Then in MasterPage you can in Page_Load or whatever you want, use the following:

_errorLabel.Text = ErrorMessagesManager.ErrorMessage;

Thanks Noor for the fast reply,

where did i use the business logic in a page

actually what i'm trying to do is seperate all the functions and business logic into files that are located in the "includes" folder (custom c# class files)

then from the pages, i'll i have to do is just call functions and they will handle the stuff

so, what i'm trying to do is what you are saying exactly but i messed it up

if you can be more helpful and tell me how would i use ErrorMessagesManager directly from my code without including or using the CS file?

if i wanted to place that class in includes folder and name it

includes/SysMsg.cs

what shall i do in the master page and in the content page that i intend to use that function in ?

I'm using ASP.net 3.5 by the way

#5

Ok. If you want to separate Data Access Layer (DAL) and Business Logic Layer (BLL) from, the Presentation Layer (PL = Website project and I recommend Web Application Project) then the best approach is to create for each one a different assembly (Class Library Project).

DAL must know about BLL which means BLL project must have a reference to DAL. And PL must know about BLL and don't know about DAL so it must have a reference to BLL and not PL.

In this case you can make sure that your application has no coupled layers.

In a real application, the business logic layer call an operation and if an error happens it may throw exceptions or notify for errors by any mechanism.

So describe exactly what you want, how to handle errors? or how to send information to the master page from a content page?

Thanks in advance

تم تعديل هذه المشاركة بواسطة نور الإسلام في 22 مارس 2010 في 15:16

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#6
نور الإسلام كتب:

Ok. If you want to separate Data Access Layer (DAL) and Business Logic Layer (BLL) from, the Presentation Layer (PL = Website project and I recommend Web Application Project) then the best approach is to create for each one a different assembly (Class Library Project).

DAL must know about BLL which means BLL project must have a reference to DAL. And PL must know about BLL and don't know about DAL so it must have a reference to BLL and not PL.

In this case you can make sure that your application has no coupled layers.

In a real application, the business logic layer call an operation and if an error happens it may throw exceptions or notify for errors by any mechanism.

So describe exactly what you want, how to handle errors? or how to send information to the master page from a content page?

Thanks in advance

well, what you said is what i'm trying to achieve at the end.

but currently i'm trying to make a login page, in the login page, there should be the box for system messages from the master page, i want that box to simply say (Please enter your information)J

in case there's an error , the system message box will show the same message"Please enter your information" + the error box will show "Information you entered are incorrect"

My problem is that i can't reach the master page controls from these BL classes

I have managed to get the login working good, the information are passed to a userscheck.cs file and that file returns true or false after checking the information

but in the case of false, i want to show an error message through SysMsgs.cs file, sending the error to that file to show it on the errors box of the master page

i hope it's clear

#7

First of all, What is the benefit of the MasterPage in your scenario?

I mean you shouldn't add the label which contains the instructions into the MasterPage from the beginning. That's because the MasterPage was invented to add the common parts of website or some pages which will appear on ALL of them. But this instruction label will eventually disappear when you go to another page. So, the right place is to add the label in the Login page not the MasterPage. Hence, it will be so easy to change the text of this label then.

Your scenario are somehow not appropriate so it is useless to write useless code to manage inappropriate scenario. But if you have some business need to accomplish what you have said, tell me.

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#8

i have to divs in the master page

one is system messages (used only when there are some instrcutions for the user)

the second is Errors div to show error messages

almost every page will have errors some how, they're mostly forms to enter data and sometimes reports that not everyone should see or maybe temporary unavailable.

these divs will be (display: none) or hidden

until there is a message, then the SysMsg.cs file should make that div visible and show the error in it or the message in it.

i want to keep those divs in the master page not on content pages.

#9

Then your scenario can be handled using the code-behind files. Rule of thumb: you can handle UI logic into pages but not business logic

What you are asking for is just a GUI logic i.e, making a div visible or not. So, you have to separate your business logic from your UI logic. You need now a mechanism to set errors to something shared between all pages including MasterPage.

In ASP.NET there are many techniques for state management. One of them is Session. Simply, use Sessions to share information between pages across postbacks. Here is a sample in the content page which threw the error:

Session["Error"] = "Error Message";

And in MasterPage you can do the following in the Page_Load:


if(Session["Error"]) ! = null
{

_errorLabel = Session["Error"].ToString();

}

تم تعديل هذه المشاركة بواسطة نور الإسلام في 22 مارس 2010 في 17:26

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#10

ايها المتفرنجون انتم فى منتدى الفريق العربى للبرمجة

1 −1

Technical Lead Developer

My LinkedIn Profile

اللهم قنى شر الجهل و الجهلاء

( اقْتَرَبَ لِلنَّاسِ حِسَابُهُمْ وَهُمْ فِي غَفْلَةٍ مَّعْرِضُونَ ) {الأنبياء:1}

#11
طارق إبراهيم كتب:

ايها المتفرنجون انتم فى منتدى الفريق العربى للبرمجة

:)

السلام عليكم ورحمة الله وبركاته يا أخ طارق :)

أنا لا أرى أي داعي في نعتنا بالمتفرنجون .. ومنتدى الفريق العربي للبرمجة .. لا يعني إطلاقاً ألا أتحدث بالإنجليزية أصلاً وإنما هو مكان يجمع المبرمجين العرب

أما كتابتي أحياناً للإنجليزية .. لأني قرأت مقالات كثيرة هنا بالعربية تتكلم عن البرمجة .. واعذرني فإني عندما أقرأها أفقد طعم البرمجة بل وأفقد حبها أصلاً هذا لأن الترجمة في كل شيء ليست جيدة .. وقد تضيف صعوبة أحياناً وهذا ما يحدث دائماً في محاولة ترجمة علم مثل البرمجة ..

هو رأي شخصي .. وأرى أنه مادامت المعلومة وصلت بالإنجليزية أو بالعربية فلا مشكلة .. فليس كل شيء يمكن ترجمته .. وهذا لا يعني أني لست ناصراً للغة العربية ... فلكل مقام مقال.

جزاك الله خيراً

تم تعديل هذه المشاركة بواسطة نور الإسلام في 23 مارس 2010 في 07:49

1

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#12
نور الإسلام كتب:

:)

السلام عليكم ورحمة الله وبركاته يا أخ طارق :)

أنا لا أرى أي داعي في نعتنا بالمتفرنجون .. ومنتدى الفريق العربي للبرمجة .. لا يعني إطلاقاً ألا أتحدث بالإنجليزية أصلاً وإنما هو مكان يجمع المبرمجين العرب

أما كتابتي أحياناً للإنجليزية .. لأني قرأت مقالات كثيرة هنا بالعربية تتكلم عن البرمجة .. واعذرني فإني عندما أقرأها أفقد طعم البرمجة بل وأفقد حبها أصلاً هذا لأن الترجمة في كل شيء ليست جيدة .. وقد تضيف صعوبة أحياناً وهذا ما يحدث دائماً في محاولة ترجمة علم مثل البرمجة ..

هو رأي شخصي .. وأرى أنه مادامت المعلومة وصلت بالإنجليزية أو بالعربية فلا مشكلة .. فليس كل شيء يمكن ترجمته .. وهذا لا يعني أني لست ناصراً للغة العربية ... فلكل مقام مقال.

جزاك الله خيراً

فعلا مشرفنا العزيز, أنا كنت متردد لفتح الموضوع هنا بالمنتدى العربي لسبب واحد فقط , هو إن كل دراستي للبرمجة وقراءاتي عنها بالإنقليزية , وهنا المصطلحات الخاصة بالبرمجة بالعربية لا اعرفها وراح تسبب عائق أمامي لإرسال أو إستقبال المعلومة, مع العلم بأني أرى خبرات أحتاج الإستفادة منها بهذا المنتدى الطيب

وموضوعي الأساسي ومشكلتي الأساسية هي بالعربية, لو هناك شخص حب يعلق علي بالعربية أنا مستعد أحاول التعاون والتحدث بالعربية قدر المستطاع

أخوي نور الإسلام

جميل جداً إقتراحك بأني أختار الـ Session كـ حل لعرض الرسائل وأعتقد إنه بسيط وأستطيع إستخدامه

ولكن, ربما أنا أخطأت في شرح ما أريد, , ما أريده وجدت عنه مواضيع باللغة الإنقليزية ولكن يبدو أنها قديمة شوي, يعني فيه ناس كثير عندهم نفس الحاجة اللي أنا محتاجها

يحتاجون يتحكمون ب Label من كلاس في App_Code لكن في حالتي بما إني Web Application ف مجلد ال App_code غير مفعل ف قمت بإنشاء مجلد includes بدلاً منه

تفضل هذا رابط موضوع باللغةا لإنقليزية يطلب نفس طلبي ولكنه لم يناسبني

http://forums.asp.ne...29.aspx#1987329

لاحظ ردود Bitmask , هو تقريباً قاعد يعالج نفس مشكلتي

لكن حله , كان دايماً يعطيني Exception في السطر هذا

set { _footer = value; }

كان الإكسبشن هو NullReference (نفس المعروض في مشاركتي الثانية بهذا الموضوع.

انا حاب إنه أعمل Standarization بالموضوع بحيث إنه الBL بالإضافة إلى (ال Functions المشتركة بين أكثر من صفحة ) تكون في مجلد ال includes

وبالنسبة لل aspx تكون فقط كما تفضلت presentation layers وإذا إحتاجت إلى طلب معين تقوم بمراسلة الكلاسات الخاصة في مجلد الإنكلودز ,

وما في مجلد الإنكلودز إما يستعلم من الداتا بيس عن طريق ال DAL أو يقوم بمعالجة المشكلة من نفس الموضع ويعيدها إلى ال PL

تم تعديل هذه المشاركة بواسطة Mohannad Otaibi في 23 مارس 2010 في 09:37

#13

If you just insist on that. I would give you another solution.

1 - Create an Interface which contains for example only one string property like this:


{

string ErrorMessage {get; set;}

}
public interface IMasterPage

2 - Let all your master pages implement this interface like this:



{

// code is here of the master page ....

protected void Page_Load(object sender, EventArgs e)
{

_errorLabel.Text = ErrorMessage;

}

// IMasterPage Implementation
public string ErrorMessage {get; set;}

}
public class MyMasterPage : MasterPage, IMasterPage

3 - In your includes folder just create a service like SysMsg.cs which will have only one method for example:


{

public static void SetErrorMessage(string errorMessage, IMasterPage masterPage)
{

masterPage.ErrorMessage = errorMessage;

}

}
public static class SysMsg

4 - From each content page which may throw an error just obtain a reference to the master page and just call the previous method

This way, you have abstracted each master page to an interface and you are just talking to an interface containing a property. This makes your design better and have no hassles about the UI of the master page. Also, gives you an opportunity to change the UI of your master page in a later stage without breaking the SysMsg.cs methods.

تم تعديل هذه المشاركة بواسطة نور الإسلام في 23 مارس 2010 في 10:25

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#14

يوجد أيضاً بعض الحلول الأخرى مثل هــذا أو هـــذا. ولكنها تتكلم فقط عن كيفية ربط الـ MasterPages بالـ ContentPages. وليس لها علاقة من قريب أو من بعيد بالسيناريو الخاص بك.

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#15

Sorry Noor

but where did you define

masterPage

which you used in the SysMsg.cs example above

by the way, there are namespaces and using statements. if there's something i should do in that regard please mention it.

Another thing.

why did you put this in the Page_load of the master page

_errorLabel.Text = ErrorMessage;

can't i just let the ErrorMessage function handle this?

نور الإسلام كتب:

يوجد أيضاً بعض الحلول الأخرى مثل هــذا أو هـــذا. ولكنها تتكلم فقط عن كيفية ربط الـ MasterPages بالـ ContentPages. وليس لها علاقة من قريب أو من بعيد بالسيناريو الخاص بك.

نعم استاذي,

مريت على أغلب هذه المواضيع وجربتها وهي تعمل لكنها تربط الfunctions بالـ code-behind الخاص بالصفحات وهذا الأمر الذي أحاول أن اتفاداه

لا أريد تكرار السطور أو الfunctions بأكثر من ملف او صفحة

تم تعديل هذه المشاركة بواسطة Mohannad Otaibi في 23 مارس 2010 في 10:43

#16

1 - إذا أردت أنت تكتب السطر التالي في SysMsg فهذا سيكون قرار خاطيء بكل تأكيد وهذا للأسباب التالية:

_errorLabel.Text = ErrorMessage;

السبب الأول: أن SysMsg بهذه الطريقة سيحتوي على Label وبهذا لن تستطيع أن تقوم باختبار هذا الـ class لأنه يعتمد على GUI

السبب الثاني: في المستقبل لو أحببت أن تقوم بتغيير ال Label الموجودة في ال MasterPage وتضع بدلاً منها مثلاً كنترول أخر وليكن ListBox هذا يعني أنك سوف تقوم بتغيير ال SysMsg وهذه مشكلة في حد ذاتها خصوصاً لو أنك قمت بإعطاء هذا الكود لعملاء بالفعل فهذا يعني أنك لكي تضيف ال ListBox عليهم جميعاً أن يتخلوا عن النسخ القديمة لأن هناك أكواد تغيرت!

السبب الثالث: أنك قمت بعمل Tight Coupling بين ال BL و بين الصفحات لأن ال BL لا يجب أن يعرف أي شيء عن أي مكون من مكونات ال UI

ولكن على كل حال هناك طريقة لما أردت .. ولكني لا أحبذها إن أردتها أرسلها لك أيضاً لا مشكلة ..

2 - بخصوص الـ variable المسمى بــ masterPage .. فهو موجود في الـ Method المسماة بـ SetErrorMessage كأنه Parameter .. في الكود التالي لاحظ الـ Parameters

public static void SetErrorMessage(string errorMessage, IMasterPage masterPage)
{

masterPage.ErrorMessage = errorMessage;

}

وفي صفحات ال Content يمكنك عمل الأتي على سبيل المثال:

protected void Page_Load(object sender, EventArgs e)
{

SysMsg.SetErrorMessage ("Error message is here",Master)

}

لكل ContentPage بها reference للـ master page الخاصة بها وهو Master.. وبما أنه Implements الـ interface الذي قمنا بعمله IMasterPage إذن ستتقبله الـ Method بكل سهولة

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#17
نور الإسلام كتب:

1 - إذا أردت أنت تكتب السطر التالي في SysMsg فهذا سيكون قرار خاطيء بكل تأكيد وهذا للأسباب التالية:

_errorLabel.Text = ErrorMessage;

السبب الأول: أن SysMsg بهذه الطريقة سيحتوي على Label وبهذا لن تستطيع أن تقوم باختبار هذا الـ class لأنه يعتمد على GUI

السبب الثاني: في المستقبل لو أحببت أن تقوم بتغيير ال Label الموجودة في ال MasterPage وتضع بدلاً منها مثلاً كنترول أخر وليكن ListBox هذا يعني أنك سوف تقوم بتغيير ال SysMsg وهذه مشكلة في حد ذاتها خصوصاً لو أنك قمت بإعطاء هذا الكود لعملاء بالفعل فهذا يعني أنك لكي تضيف ال ListBox عليهم جميعاً أن يتخلوا عن النسخ القديمة لأن هناك أكواد تغيرت!

السبب الثالث: أنك قمت بعمل Tight Coupling بين ال BL و بين الصفحات لأن ال BL لا يجب أن يعرف أي شيء عن أي مكون من مكونات ال UI

ولكن على كل حال هناك طريقة لما أردت .. ولكني لا أحبذها إن أردتها أرسلها لك أيضاً لا مشكلة ..

2 - بخصوص الـ variable المسمى بــ masterPage .. فهو موجود في الـ Method المسماة بـ SetErrorMessage كأنه Parameter .. في الكود التالي لاحظ الـ Parameters

public static void SetErrorMessage(string errorMessage, IMasterPage masterPage)
{

masterPage.ErrorMessage = errorMessage;

}

وفي صفحات ال Content يمكنك عمل الأتي على سبيل المثال:

protected void Page_Load(object sender, EventArgs e)
{

SysMsg.SetErrorMessage ("Error message is here",Master)

}

لكل ContentPage بها reference للـ master page الخاصة بها وهو Master.. وبما أنه Implements الـ interface الذي قمنا بعمله IMasterPage إذن ستتقبله الـ Method بكل سهولة

للأسف جربت وهذا اللي طلع لي

Inconsistent accessibility: parameter type 'intTest.includes.IMasterPage' is less accessible than method 'intTest.includes.SysMsg.SetErrorMessage(string, intTest.includes.IMasterPage)
#19
نور الإسلام كتب:

هل ال interface .. مرئي للكل public ؟

انا تركته كما جاء

كان

interface IMasterPage

لم يكن قبله public أو غيرها

لكن جربت اضع public ,طلع لي إيرور ثاني اللي هو:

Error 1 The name 'master' does not exist in the current context intTest

#20

1 - If you leave the interface as it is it will be considered internal by default in .NET so make sure always that you put the accessbility level of any type whether it was internal or public and in your case it must be public.

2- Can you send me your code because I don't know what is this "master" which appears in the errro?

Thanks

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#21

intTest.rar

نور الإسلام كتب:

1 - If you leave the interface as it is it will be considered internal by default in .NET so make sure always that you put the accessbility level of any type whether it was internal or public and in your case it must be public.

2- Can you send me your code because I don't know what is this "master" which appears in the errro?

Thanks

intTest.rar

تفضل اخوي نور , حاولت ارسله لك على رسالة خاصة أو عالبريد وماحصلت لك عنوان وعن طريق المنتدى هنا تنقصني الصلاحيات حيث إني مسجل الدخول عن طريق الفيس بوك

هذا الملف فيه بروجكت للتجربة عملته انا فقط لأتأكد من عمل الطريقة التي أريدها

بعد ما يعمل بالشكل اللي أحتاجه راح انقل الطريقة بأشكال مختلفة للبروجكت اللي أنا أعمل عليه حالياً

إذا حاب نسخة من البروجكت كامل ماعندي مشكلة لكن احتاج طريقة تواصل خاصة

#22

هذا سوف يحل مشكلتك ..

        protected void Page_Load(object sender, EventArgs e)
        {
            SysMsg.SetErrorMessage("Hey", Master as IMasterPage);

        }

سوف تلاحظ هذا التغيير Master as IMasterPage سيحل مشكلتك إن شاء الله

مدونة ابنتي الرضيعة: يوميات رزان

مدونتي التقنية العربية: البرمجة مع عبد المنعم

Technical Blog: Abdul Moniem's Thoughts

LinkedIn: Profile

#23

ينصر دينك ياشيخ, ضبط الموضوع زي الحلاوة

I'll move on with the project and see how it goes

تم تقييمك + وتستحقها من ردك الأول أستاذي الكريم

#25

هذا Sample للبروجكت لعموم الفائدة

intTest.rar

مواضيع مشابهة