Sunday, August 1, 2010

Hide a Button using JavaScript

Suppose there is a ASP.NET button with ID=btnSubmit..You want to make it invisible on the okclick event of an anchor tag :


write the below function in javascript :

function F1()
    {
    alert('ravi')
    document.getElementById("btnSubmit").style.visibility="hidden"
    }

Friday, July 2, 2010

Unable to host WCF Service in remote machine and Use it

You see WCF service works fine  if you use it in the application which resides in the same machine as that of
WCF service.But if you try to host the WCF service in remote machine and use it from your application,you can not add service reference even though you have given correct reference url..

Change Binding to basicHttpBinding from WsHttpBinding. of your WCF Service and rebuild.
Then add a reference to the service which is hosted in your local machine--say http:\\youripaddress\MyService\Service1.svc to the application.
Change the endpoint address

 < endpoint address="http://192.168.160.58/MyService/Service1.svc"              
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDALService"
                contract="CRSService.IDALService" name="BasicHttpBinding_IDALService" />

This solves your problem.

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, DB Wrap Policy]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)

Remove app.config from ClassLibrary.
Make the Setting you have done say EntLib Blocks-Logging and ExceptionHandling etc on the config file
of WCF Service or Application in which you are using the reference of class library.
It resolves your error..
Happy Coding,Hurray !

Friday, December 4, 2009

Code to Add Controls dynamically to Form

for (int k = 0; k &lt; 5; k++)

{

TextBox t = new TextBox();

this.form1.Controls.Add(t);

LiteralControl l = new LiteralControl("&lt;br/&gt;");

this.form1.Controls.Add(l);

}



Note:We have taken the help of literal controls to place a TextBox in NextLine.
Here we are generating 5 TextBoxes.

PlaceHolder PlaceHolder1 = new PlaceHolder();

for (int i=1; i<=10; i++)
{
Label lbl = new Label();
lbl.Text = "Label" + i.ToString();
lbl.ID = "Label" + i.ToString();
PlaceHolder1.Controls.Add(lbl);
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
} 

Here we are adding 10 Labels.

Monday, November 16, 2009

sys is undefined

The reason for this error is your web.config does not contain all the settings required for an ajax enabled web site.
First , generate an ajax enabled web site namely ajaxsite1 and compare your web.config with that of ajaxsite1.
you observe that code in httpHandlers  is not there in your website or it might be improper.
Replace the web.config code in ajaxsite1 in to your website.
See that after running you will ge 'Done' at the bottom left.Previously you get 'Done with Errors' message in this portion.
Note:
All this errors and exceptions generally occur if you are working with Ajax Controls.You will  not get your ajax controls functionality in your  webpage unless you clear all these script errors.
Some of the controls that may raise this error are AutoComplete,CalendarExtendar etc