كود سهل وبسيط للطباعة داخل صفحة انترنت حيث يطبع كل شئ بالجرافيك وبنفس الشكل وبنفس الاستايل كما في الديزاين

اسهل طريقة للطباعة بدون الكريستال ريبورت Printing pages in asp.net

اسهل طريقة للطباعة بدون الكريستال ريبورت Printing pages in asp.net

طباعة جزء من الصفحة او طباعة كامل الصفحة او طباعة صورة بجرافيك عالي الجودة بدون الحاجة للكريستال ريبورت او لاي اداة للطباعة داخل الدوت نت

باختصار يمكنك طباعة اي شئ بهذا المثال  وعلي سبيل الامثلة لا الحصر . يمكنك طباعة الجريد فيو - الداتاليست- اللايبل - اي جزء من الصفحة ....

print page in asp.net

print part of page in asp.net

print GriedView in asp.net

print Datalist in asp.net

print chart in asp.net

Print labels and textbox in asp.net

باختصار طباعة اي شئ تريده بمنتهي السهولة سواء في المشروع او بعد رفعك للمشروع علي استضافة

 

 

 

 

توجد للطباعة في الدوت نت  print in Asp.net اساليب مثل

-          الكريستال ريبورت  crystal report in asp.net

-          ريبورت فيور في الدوت نت  report viewer

-          الجريد فيو (تطويع الجريد فيو ومثيلتها في الطباعة باشكال معينة ) وكل ذلك تم شرحه في المحاضرات الخاصة بالتقارير

 

لكننا الان بصدد كود سهل وبسيط وبدون اي مشاكل في الاستضافة التي تدعم هذا او ذاك فقط وهكذا

 

 تحميل المثال البرمجي من هنا

كيف يتم ذلك

هنا سوف اضع اي شئ مراد طباعته في صورة كونترول مثلا ديف او جدول

ثم سوف انادي علي هذا الجدول او الفورم او الديف div

التي تحتوي الاشياء المراد طباعتها

 

تجربة عملية بصور

 print in asp.net

 print in asp.net

 

 

الخطوة الاولي

ننشأ صفحة انترنت فارغة ثم تعبئتها بما تريد طباعته هنا انا وضعت مثال بسيط مثل صورة بجرافيك عالي

وايضا لايبل وزرارين ووضعت كل شئ منسق داخل جدول وهم 4 صور

-          زر للطباعة لجزء من الصفحة

-          زر لطباعة كامل الصفحة

 

print in asp.net

 

 

print in asp.net

الخطوة الثانية

انشاء صفحة ويب عادية لا تتبع اي ماستر باج ووضعت في حدث بداية الصفحة page_load

 

  // وضعت الكونترول المراد طباعته في سشن بكامل ما يحتوية من معلومات

            Control ctrl = (Control)Session["print"];

            // ثم اخبرت الكلاس الخاص بالطباعة بان ما سيطبعه هو الكونترول المرسل في سشن

            PrintHelper.PrintWebControl(ctrl);

 

 

يتبقي خطوة  ثالثة

 

انشاء كلاس الطباعة وهنا سوف  انشأ كونترول وكلمة كونترول قد تكون اي شئ مثل جدول او ديف او اي شئ اخر

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

 

print in asp.net

ننشأ كلاس اسمه  PrintHelper

يعمل علي انشاء فورم الطباعة تلقائيا حيث يأخذ اسم الكونترول المراد طباعته .

 

 

 

public PrintHelper()

    {

        //

        // TODO: Add constructor logic here

        //

    }

    public static void PrintWebControl(Control ctrl)

    {

        // امر طباعة للكنترول

        PrintWebControl(ctrl, string.Empty);

    }

 

    public static void PrintWebControl(Control ctrl, string Script)

    {

        // نسخة من الكلاس سترينج رايتر النصي

        // ثم نكون الكونترول المراد طباعته لاننا نضع اي شئ نريد طباعته في كونترول مثل جدول او ديف او اي شئ اخر

        StringWriter stringWrite = new StringWriter();

        System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);

        if (ctrl is WebControl)

        {

            Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;

        }

        // هنا نكون الصفحة

        Page pg = new Page();

        pg.EnableEventValidation = false;

        if (Script != string.Empty)

        {

            pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);

        }

        // ثم نكون الفورم الذي يحوي كل ذلك

        HtmlForm frm = new HtmlForm();

        pg.Controls.Add(frm);

        frm.Attributes.Add("runat", "server");

        frm.Controls.Add(ctrl);

        pg.DesignerInitialize();

        pg.RenderControl(htmlWrite);

        string strHTML = stringWrite.ToString();

        HttpContext.Current.Response.Clear();

        HttpContext.Current.Response.Write(strHTML);

        HttpContext.Current.Response.Write("<script>window.print();</script>");

        HttpContext.Current.Response.End();

    }

 

 

 

الخطوة الرابعة والاخيرة

ففي زر الطباعة  نضع الكود الاتي

  protected void Button1_Click(object sender, EventArgs e)

        {

            // هنا طباعة كل الصفحة حيث نرسل اسم الديف الذي يحتوي بداخله علي كل الادوات المراد طباعتها

            // حيث وضعت اسم الديف في سشن

            Session["print"] = divprintAll;

 

            //  هنا من خلال كود جافا سكربت يتم فتح صفحة ويندو صغيرة وبها اسم الصفحة المسماة 

            //printPage.aspx والخاصة بفتح السشن الذي به الاشياء التي سوف تطبع

            ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('/printPage.aspx','PrintMe','height=400px,width=550,scrollbars=1');</script>");

 

        }

 

 

طبعا الزر الذي يطبع جزء من الصفحة نضع ايضا اسم الديف فقط

print part of the page in asp.net

 

تنوية بسيط

اذا كنت تستخدم ستايل معين لكي يعمل داخل الديف بنفس الشكل ويظهر في الطباعة لابد من

-          اما وضع او القاء الستايل داخل الديف المراد طباعتها وليس في وسم الهيد فقط

 

 print in asp.net

بالضغط علي زر طباعة كامل الصفحة سوف يطبع كل شئ

print in asp.net

 

 

بالضغط علي زر طباعة جزء من الصفحة سوف يطبعالجزء المحدد فقط

print in asp.net

 

 تحميل المثال البرمجي من هنا

ways to terminate an early pregnancy abortions want an abortion
chlamydia drug treatment phuckedporn.com treatment for gonorrhea
what happens in an abortion click abortion weeks
my husband and i both cheated open why i cheated on my husband
my husband and i both cheated open why i cheated on my husband
i had a dream that my girlfriend cheated on me go i had a dream my girlfriend cheated on me
i had a dream that my girlfriend cheated on me go i had a dream my girlfriend cheated on me
what to do when your wife cheated on you so your wife cheated on you i want to cheat on my wife
i love my wife but i want to cheat open cheat on your wife website
i love my wife but i want to cheat read cheat on your wife website
wives who cheat link how to know if wife has cheated
when your husband cheats maryaltmansblog.com.nobullsoftware.com why wife cheat
abortion doctors read medical abortion nhs
cell spy monitoring software spy app for android free spy cell phones
denver abortion clinics abortion pill when is it too late to get an abortion
pharmacy prescription discount card open walgreen printable coupons
photo deals walgreens wrightcontractingsi.com walgreens photo prints coupon
photo deals walgreens wrightcontractingsi.com walgreens photo prints coupon
discount coupons for medications free prescription discount card petmart pharmacy coupons
discount coupons for medications discount pharmacy online petmart pharmacy coupons
drug prescription card discount prescription drug cards coupons for prescription drugs
can i take loratadine while breastfeeding click can i take loratadine while breastfeeding
cheap cialis prices click cialis price generic
coupons for prescriptions canada drug pharmacy coupon new prescription coupons
canada drug pharmacy coupon link cialis discount coupons online
discount coupon for cialis 2015 cialis coupon prescription drug cards
cymbalta preis cymbalta dosierung cymbalta 60 mg
cymbalta preis go cymbalta 60 mg
discount coupons for cialis cialis discount coupons cialis manufacturer coupon
amoxicillin endikasyonlar amoxicillin amoxicillin-rnp
cialis discount blog.pelagicfm.com cialis discount
cialis free sample coupons manufacturer coupons for prescription drugs free cialis coupon 2016
cialis free sample coupons manufacturer coupons for prescription drugs free cialis coupon 2016
amoxicillin nedir achieveriasclasses.com amoxicillin dermani haqqinda
amoxicillin nedir amoxicillin antibiyotik fiyat amoxicillin dermani haqqinda
discount coupons for cialis cialis coupons and discounts prescription discount coupon
vermox cena community.vitechcorp.com vermox brez recepta
amoxicillin dermani haqqinda accuton.com amoxicillin al 1000
risperdaloro risperdal avis risperdal
crestor card crestor 20 mg tablet crestor price australia
cialis discount coupons aldwych-international.com discount coupons for cialis
amoxicillin 500 mg alexebeauty.com amoxicillin
acetazolamide sivuvaikutukset charamin.jp acetazolamide symptoms
abortion pill services types of abortion pill abortion pill law
discount prescription coupons discount prescriptions coupons cialis coupons from lilly
vermox doziranje vermox bez recepta vermox sirup cijena
amoxicillin 500 mg mipnet.dk amoxicillin nedir
feldene flash feldene flas para que sirve feldene flash
cialis free sample coupons funtimeleisure.co.uk coupons prescriptions
addyi suomi addyi review addiyar newspaper
amoxicillin 500 mg amoxicillin nedir amoxicillin 1000 mg
cialis 2015 coupon cialis coupon card cialis prescription coupon
abortion pill online abortion clinic in dc clinics for abortion
new prescription coupon copay cards for prescription drugs lilly coupons for cialis
for abortion ivan.blogs.chimerical.com.au abortion clinics atlanta ga
prescription savings cards cialis coupons 2015 prescription coupon
cialis prescription coupon blog.askform.cn coupons cialis
naltrexone order link naltrexone natural alternative
does naltrexone cause weight loss naltrexone pills what is revia
naltrexone ingredients site once a month shot for opiate addiction

نشكرك علي المشاركة