You can contact for any type of query related to asp.net, C#, MVC,WCF,Jquery and AngularJS Follow me on - GitHub - https://github.com/mesan21ster/ YouTube Channel - https://www.youtube.com/user/mesan21ster/ Site : - https://sites.google.com/view/4dotnet
Thursday, September 10, 2009
Convert Numbers with 2 decimal places in GridView Field
use
Text='<%# Bind("Project_cost", "{0:N}") %>'
in itemTemplate of that field
it will automatically convert your number field with 2 decimal places
If you are using boundField and wants to doing same
use
DataFormatString="{0:N}"
in that boundField it will automatically convert your number field with 2 decimal places
Keep visiting for more Information
sites.google.com/site/santo01org/
Best of luck
Convert Numbers with 2 decimal places in gridview Template field
Note:
if you are using template field in gridview and wants to convert number field in decimal places(2 and more places) just use Text='<%# Bind("Project_cost", "{0:N}") %>' in itemTemplate field.
It will convert your field values with 2 decimal places
like : your number is -44
after converting - 44.00
Same thing if you want to do with bound field use DataFormatString="{0:N}" in the required field
Keep visiting for more Information
sites.google.com/site/santo01org/
Best of luck
Tuesday, September 8, 2009
Usage of doPostBack in a real environment
input type="text" name="t2" id="Tx2" runat="server"
//script for postbacking
script language="javascript"
function enablePostBack()
{
//T1 is the first argument(name of our control) I mentioned earlier and give the
// value of second argument as "" that's all
__doPostBack("Tx1","");
}
/script
//c# functon
protected void Text1_ServerChange(object sender, EventArgs e)
{
Tx2.Value = (Int16.Parse(Tx1.Value) * 45).ToString();
}
How to create runtime click event on runtime button in asp.net?
protected void Page_Load(object sender, EventArgs e)
{
tb = new TextBox();
btn = new Button();
form1.Controls.Add(tb);
form1.Controls.Add(btn);
btn.Text = "Save";
btn.Click += new EventHandler(btn_click);//generating Event
}
protected void btn_click(object sender, EventArgs e)
{
tb.Text = "hello";
}
Calling Web services Through JavaScript/html
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
//Now use this html code to call web method use head tag for javascript
function InitializeService()
{
Myservice.useService("http://localhost:4765/WebServices/Service.asmx?wsdl", "MyMethod");
//you can use anything in the place of MyMethod
}
function tst(){
//alert('hi');
Myservice. MyMethod.callService("HelloWorld");
//if your web service contains some parameters then set parameters after function name like //("HelloWorld","1","admin")
}
functionShowResult(){
alert(event.result.value);
//Myservice.innerHTML= "Resultado : " + event.result.value;
}
// then on body onload write code
onload="InitializeService()" onresult="ShowResult()"
form id="form1" method="post"
// call javascript function on button click
button onclick="tst()" id="Button1">Call Add Web Method
//use htc file
div id="Myservice" style="behavior:url(webservice.htc)"
Note:
Friends Calling Web Services is a biggest problem with as , I found the logic behind it and I want to share.
First of all we should have a HTC file (U can download from
http://sites.google.com/site/santo01org/javascript-and-web-service
) which is nothing just a HTML file with the complete information of XML http and javascript( a common file for all)Then use the above JavaScript in call page and see the magic.
Best of Luck
disable the back button for All browsers
function noBack(){window.history.forward();}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack();}
window.onunload=function(){void(0);}