July 2008 - Posts

asp.net control adapter

 

after viewing the video.and browse some msdn. the most obvious example is when you are using mobile browser .it is probably in the context of providing alternate renderings of controls for mobile devices 

Adapter is used to intercept the default rendering behaviour for an asp.net server control.mostly not required but for some cases . for customized rendering with different browser.

 

there are 4 types actually, but i haven't explore yet.

you can a class that inherit webcontroladapter

usually overrides 3 method, begin render tag, end render tag, and render contents.

you can customize a server control default rendering way.

 

after that you add the new item -> browser file.

and bind which adapter for which server control and for which browser

 

ex:

<browsers>

//default means for every browser

<browser refID="Default">

 <controlAdapters>

<adapter controlType="namaspace.namacontrol" adapterType="namaclassadapterkamu:"/>

 

 

 

Share this post: | | | |
Posted by cipto with no comments
Filed under:

SSRS

whoah it's been 1 days to solve this issue,

everything below is using local report with SSRS not report server.

when using localreport with Microsoft report viewer, been quite a mystery, when somethings got wrong , it just display simple error which also a mystery. i search the net but found not a brief explanation

any way , when you are using sub report, the trouble gots higher.

you've got to manually bind the value for each object data source.

First step is to add event handler

Page load

{

     ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
   
     ReportViewer1.ReportRefresh += new System.ComponentModel.CancelEventHandler(ReportViewer1_ReportRefresh);
    }

    void ReportViewer1_ReportRefresh(object sender, System.ComponentModel.CancelEventArgs e)
    {
        ObjectDataSource1.DataBind();
        ObjectDataSource2.DataBind();
        ObjectDataSource3.DataBind();
    }
////this is processed row by row

//you've got to attach the report parameter to object datasource

//on local mode you need to do this

   void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e)
    {

        e.DataSources.Add(new ReportDataSource("SubWipproposal_WipProposal", "ObjectDataSource2"));
        ObjectDataSource2.SelectParameters[0].DefaultValue = e.Parameters[0].Values[0];
        e.DataSources.Add(new ReportDataSource("PipeLineDataset_GetProducttype", "ObjectDataSource3"));
        ObjectDataSource3.SelectParameters[0].DefaultValue = e.Parameters[1].Values[0];
        ObjectDataSource3.SelectParameters[1].DefaultValue = e.Parameters[0].Values[0];

    }

Error: SubReport could not be shown

Solution:

1.Check every data source: the main report and the sub report , by clicking vside menu , report ->Datasource , already included the source of your report, add as necessary

2.Check  the naming of the dataset,report ->Datasource,must match  from the add report datasourcename (case sensitive) on subreportprocessing event

3.CHeck that your sub report parameters already define the same as the parameters being pass from main report

Error: "Text box.A Scope..."    

Solution: for multiple dataset in one report you  need to define the scope of each textbox. for ex:(=First(Fields!producttype.Value, "PipeLineDataset_GetProducttype") the bold one is the scope

 

when using multiple datasource, it's better to use .List and then in that list there's a sub report

Hope this help

Mark as answer :) :)

Share this post: | | | |
Posted by cipto with no comments
Filed under:

Zoom tool

ok, i've seen my friend use zooming tool on .net ide. but i don't now if this is the one.

any way sometimes my monitor resolution is too small, i can't see the god damn code.

then use this tool

http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx

when u press ctrl 1(Default=>can bee customized

it enlarge and you can scroll to make it larger

 

 one feature that i like, and it helps u when you are stress is drawing on the ide

 :) Syaloom

Share this post: | | | |
Posted by cipto with no comments

Security Trimming

one of my developer fellow ask me his name is manumpak, 

how do i make previlleges for pages and combining them by restricting/hidding the menu based on role.

in indonesian="Bagaimana caranya supaya Halaman hanya bisa di buka berdasarkan peranan Mis: Sales hanya bisa lihat report sales, Marketing lihat Marketing report Dan Menunya di halaman default bisa hilang(Sesuai Peranan))".

approach:

1. can code on master page

2. on base page

OR

u can use security trimming from asp.net 2.0.

 1. Enabled on web.config

 <system.web>
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
      <providers>
        <add name="XmlSiteMapProvider" description="Default SiteMap provider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
      </providers></siteMap>

 2.Make Every SiteMapNode on Web.sitemap contains Roles statement

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"  >
    <siteMapNode url="Default.aspx" title="Home"  description="Home" roles="SME,EWO,CSA,FACTORY,Commercial">
      <siteMapNode url="SalesSME.aspx" title="Sales SME"  description="Sales SME" roles="SME" />
      <siteMapNode url="EWO.aspx" title="EWO"  description="EWO" roles="EWO"/>     
    </siteMapNode>
</siteMap>

 3. There are connection between these sitemapnode to authorization tag, which must specify to make this Trimming works(THIS IS THE MAIN TRICK

 <location path="EWO.aspx">
        <system.web>
            <authorization>
                <allow roles="EWO"/>
                <deny users="*"/>
            </authorization>
        </system.web>
    </location>
  <location path="SalesSME.aspx">
    <system.web>
      <authorization>
        <allow roles="SME"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>

 4. To Test it make a user and give role to it.

 on global asax place these following code:

void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        //Create Role
        if(!Roles.RoleExists("Commercial"))
            Roles.CreateRole("Commercial");
        if (!Roles.RoleExists("CSA"))
            Roles.CreateRole("CSA");
        if (!Roles.RoleExists("EWO"))
            Roles.CreateRole("EWO");
        if (!Roles.RoleExists("Factory"))
            Roles.CreateRole("Factory");
        MembershipUser cipto = Membership.GetUser("cipto");
        if (cipto == null)
        {
            try
            {
                Membership.CreateUser("cipto", "ciptodeveloperterganteng","cipto@Plasxxxxx.com");
                Roles.AddUserToRole("cipto", "EWO");
            }
            catch (Exception ex)
            {
           
            }
        }
       
    }

5. Create The menu on Default Page.you can use asp TREE, or ultrawebmenu and place sitemapdatasource

 

 6. Deny anonymous authorization '?'

 7. Login from your login page .

8.You should see only EWO menu

 

 jamekovacs have made own httpmodule, map from exists role from ntaccount if windows authentication and from Roles if Form authentication.

and map to an xml, so we just modified the xml for easiness.

 http://www.jameskovacs.com/blog/DevelopingAndTestingRoleBasedASPNETApplicationsWithImpostorHttpModule.aspx

you can add the httpmodule on web.config

    <httpModules>
            <add name="ImpostorHttpModule" type="JamesKovacs.Web.HttpModules.ImpostorHttpModule, JamesKovacs.Web.HttpModules"/>
    

There you are. Hope it helps.

Have a nice week end

Share this post: | | | |
Posted by cipto with 5 comment(s)
Filed under: