Friday, September 12, 2008

How to get value from Checkboxlist using javascript

I read many of the thread regarding to how to get value from the check box list using javascript.....

Here i am describing how you get the value from the check box list using javscript

JavaScript
----------
function getName1()
{

var chkText = '';
var chktable = document.getElementById('chklistInterests');
var chktr = chktable.getElementsByTagName('tr');

for(var i=0; i ;lt chktr.length;i++)
{
var chktd = chktr[i].getElementsByTagName('td');
for(var j=0; j
;lt chktd.length; j++)
{
var chkinput = chktd[j].getElementsByTagName('input');
var chklabel= chktd[j].getElementsByTagName('label');
for(k=0;k ;lt chkinput.length;k++)
{
var chkopt = chkinput[k];
if(chkopt.checked)
{
chkText = chkText + chklabel[k].innerText + ',';
}
}
}
}
alert( chkText);
}

Tuesday, August 12, 2008

How to send mail through asp.net using smtp server?

Here is code for sending mail through SMTP server

SmtpClient objSmtpClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"].ToString());

// Here, Pass your SMTP Server Name, Default is 'localhost'
objSmtpClient.Host = "YourSmtpServer";
objSmtpClient.Port = 25;

MailMessage objMailMessage = new MailMessage();
MailAddress objMailAddress = new MailAddress(From);
objMailMessage.From = objMailAddress;
objMailMessage.To.Add(To);
objMailMessage.Subject = Subject;
objMailMessage.IsBodyHtml = true;
objMailMessage.Body = "Test";
objMailMessage.Priority = MailPriority.High;
objSmtpClient.Credentials = new
System.Net.NetworkCredential("SmtpServerUserName","SmtpServerPassword");
objSmtpClient.Send(objMailMessage);

Monday, July 14, 2008

How to use web service in PHP 5.1.6. Part -> 2

In my previous post i describe how to create a web service and how to used in asp.net? In this post i used my web service in php.

First i create one page in php.
include_once('xmlparsefunction.php');

$client = new soapclient
(
'http://yourservername/web/getinvoicestatus/getinvoicestatus.asmx?WSDL',
array( 'trace' => true,
'exceptions' => true,
)
);

$param = array('strUserName' => 'aaa','strPassword' => 'bbb','strSecurityCode' => 'ccc');

$rs1 = $client->__call('getcompanyservice',array($param));

$result['getcompanyserviceResult']=$rs1->getcompanyserviceResult;

$rs = xml2array(htmlspecialchars($result['getcompanyserviceResult']));
print_r($rs)
?>

Wednesday, July 2, 2008

How to use web service in asp.net - Part -> 1

There are few step to add a new web service to asp.net

-> First create a new web application.

-> Then go to your project and right click and see there is one option "Add Web References".



-> Then you got this type of pop up window on your screen and in this you enter your web
service url and click "go" button near the url text box. You give one name to your web service
say "Test" above the "Add Reference" button. then click this button and you see they create a
new folder in the "App_WebReferences" and in that floder they create your "Test" floder and
put your web service in this folder.




-> Now in you sample.aspx.cs page add reference of that web service this way.
using Test;
-> Now in pagload or any event you want to used this web service in your page this way. I write
in page load event. To print "Hello wrold".

protected void Page_Load(object sender, EventArgs e)
{
Service objservice = new Service();
Response.Write(objservice.HelloWorld());
}

-> Run This sample and you got this result.

Create a web service in asp.net

There are few step to create a new web service.

1) Create a new web service application say "TestService". In that you get "Service.asmx" file.

2) In "Service.asmx" file you got this type of content.

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service ()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}

3) When you run this web service application you got this type of



Here you see there is one method "HelloWrold" and other detail of web service.
Click on this method and you get this type of content



In this there is one button "Invoke". When you clik that button you get result
of your web service.

Hello World

4) Take a path for your web service at this time your path like this
http://localhost:3406/TestService/Service.asmx

Or

If you deploy this web service into iis then you get different pathe like this
http://youeservername/TestService/Service.asmx