adsense

Saturday, May 30, 2020

ASP.NET MVC using data attributes in html helper classes

You can use data  attributes in html helper classes as displayed below.

@Html.TextBoxFor(model=> model.PostCode, new { data_validate = "true" })

Cheers,
Samitha

Sunday, May 24, 2020

communicating with an IFRAME

I wanted to automatically resize the content of an iframe for one of my projects.  I tried several solutions and done several  google searches to find a working solution for my issue. I got the initiative  from here and it helped me to achieve what I needed.

 Parent page

<head>

<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous">
</script>

<script type="text/javascript">
         // addEventListener support for IE8
            function bindEvent(element, eventName, eventHandler) {
                if (element.addEventListener) {
                    element.addEventListener(eventName, eventHandler, false);
                } else if (element.attachEvent) {
                    element.attachEvent('on' + eventName, eventHandler);
                }
            }
         
            // Listen to message from child window
            bindEvent(window, 'message', function (e) {
         
                var height = parseInt(e.data.height);
         
                if (!isNaN(height)) {
$('iframe[id="frame1"]').css('height', height + 'px');
                }
            });
</script>

<head>

<body>

<iframe id="ConnXCareersFrame1" src="https://abcd.com/index.html"  width="1000" frameborder="0" scrolling="no"&gt;&lt;/iframe>

<body>;

Child page

<head>

<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous">
</script>

<script type="text/javascript">
var height =$('body,html').outerHeight() ;

 window.parent.postMessage({
                    'height': height
                }, "*");

</script>


<head>

<body>

<div>
 <!--content here -->
</div>

<body>;

Cheers,
Samitha

Sunday, May 17, 2020

docker: “build” requires 1 argument

When you  are trying to build a docker image from the docker website, you might encounter following error.

docker build -t dockerTest/redis
docker: "build" requires 1 argument. See 'docker build --help'

This error occurs when you use the Dockerfile in the local directory This error can be avoided by adding a dot in the end as displayed below.

docker build -t dockerTest/redis .

Note that if you using docker 1.5 you can specify a Dockerfile in another place.

docker build -f, --file=""

Cheers,
Samitha

Thursday, May 7, 2020

Powershell Install-Module error


The Install-Module command is used to  install or update modules. When you are trying to execute Install-Module  you might encounter following error 

Install-Module: The term Install-Module is not recognized as the name of cmdlet, function, script file or operable program

The cause of this errors is your PowerShell is not upto date.  To execute this command major virsion of PwerShel should be greater than 5.


This issue can be resolved by installing  Windows Management Framework 5.1  

Cheers,
Samitha


Friday, May 1, 2020

Azure Functions Core Tools

If you are going to work with Azure Functions , Azure Functions Core Tools is a must have tool set to be installed.

to install with NPM

npm i -g azure-functions-core-tools@3 --unsafe-perm true


Read more information here.

Cheers,
Samitha