Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Wednesday, March 28, 2012

Calling a simple Web Service from an ASPX page

Hi

I created a new Atlas web project, added a new web service and web page using the the code from the Simple.aspx and SimpleService.asmx.

Given I have identical code in the page and ws, I end up with 'Quickstart' is undefined error, on the following line of javascript:

requestSimpleService = Quickstart.Samples.SimpleService.EchoString(
document.getElementById('inputName').value, //params
OnComplete, //Complete event
OnTimeout //Timeout event
);

Any ideas?

It turns out in VS2005, when a new web service is created a code-behind is also created and placed into the App_Code directory. The problem I was getting was becuase the namespace reference was not the same as in the asmx.

Problem solved.


Great! Note that this behavior is optional, so if you prefer you can get the code inline in the asmx file (it's a checkbox on the add dialog).

David

Monday, March 26, 2012

calling a javascript function in tabpanels button

Hi

I want to call a javascript function on a button_click() event. I was able to call this function without using tabcontrol. but I want to call this function by clicking on a button which is inside a tabpanel control .

Thanks in Advance

It should work, what is you code?

Can you provide a repro?


I have two tab panels , first one showinggoogle map .

<cc1:TabPanel ID="tab_google" runat="server">

<HeaderTemplate>Google Map</HeaderTemplate>
<ContentTemplate>
<div id="map" style="width:617;height:400" >

</div>
<input type="hidden" id="go" runat="server"/>
</ContentTemplate>
</cc1:TabPanel>

Its woking properly

and second tab panel having two <select> control.

See Below for Code

<cc1:TabPanel id="tab_distancecalc" runat="server" >
<HeaderTemplate>Distance Calculator</HeaderTemplate>
<ContentTemplate>
<div id="distance_calc" >
<form name=xyz>
<table cellspacing=0 cellpadding=0 align=center border=0>
<tbody>
<tr>
<td><font face=Verdana color=#800000 size=-1><b>Originating Point :</b></font></td>
<td align=left><b><font face=Verdana color=#800000 size=-1>Terminal Point :</font></b></td>
</tr>
<tr>
<td align="center">
<select size=12 name=abc>
<option
value=/1/0.158995591/-1/1.369611552 selected>Abiramam ,TN</option>
<option value=/1/0.526186067/-1/1.295638007>Abohar ,Punjab</option>
<option value=/1/0.371031746/-1/1.353291005>Achalpur ,Maharashtra</option>
<option
value=/1/0.275936067/-1/1.396306437>Addanki ,AP</option
<option
value=/1/0.343536596/-1/1.371362434>Adilabad ,AP</option>

</select>
</td>

<td align=middle>
<select size=12 name=pqr>
<option
value=/1/0.158995591/-1/1.369611552 selected>Abiramam ,TN</option
<option value=/1/0.526186067/-1/1.295638007>Abohar ,Punjab</option>
<option value=/1/0.371031746/-1/1.353291005>Achalpur ,Maharashtra</option>
<option
value=/1/0.275936067/-1/1.396306437>Addanki ,AP</option>
<option
value=/1/0.343536596/-1/1.371362434>Adilabad ,AP</option>
<option
value=/1/0.27280291/-1/1.349202381>Adoni ,AP</option>
<option
value=/1/0.410181658/-1/1.502780423>Adra ,WB</option>
</select>
</td>
</tr>
</tbody>
</table>
<p align="center">
<input onClick=DoCalc() type=button value=" Measure " name="button"></p>
<asp:Button ID="btn_mesure" runat="server" Text="Mesure" OnClientClick="DoCalc() return false" CausesValidation="False" ValidationGroup="distance_calc" />
</form>
</div>

</ContentTemplate>
</cc1:TabPanel>

Here is Java Script (This Java Script function should display distance )

<script language=JavaScript>
<!-- Begin
var eind=new Array();
var tourism=new Array();
var a=0;
var b=0;
function DoCalc() {
if (xyz.abc.options[xyz.abc.selectedIndex].value == null || xyz.pqr.options[xyz.pqr.selectedIndex].value==null) {
alert("Please enter both an Originating and a terminal place.");
}
else {
eind=xyz.abc.options[xyz.abc.selectedIndex].value.split("/");
tourism=xyz.pqr.options[xyz.pqr.selectedIndex].value.split("/");
d=Math.acos(Math.sin(eind[2])
*Math.sin(tourism[2])
+Math.cos(eind[2])
*Math.cos(tourism[2])
*Math.cos(eind[4]-tourism[4]));
a=Math.round(3956.073*d);
if (Math.sin(tourism[4]-eind[4]) < 0) {
b=Math.acos((Math.sin(tourism[2])
-Math.sin(eind[2])*Math.cos(d))
/(Math.sin(d)*Math.cos(eind[2])));
}
else {
b=2*Math.PI
-Math.acos((Math.sin(tourism[2])
-Math.sin(eind[2])
*Math.cos(d))/(Math.sin(d)
*Math.cos(eind[2])));
}
b=b*(180/Math.PI);
alert("Distance measured is:" +" " + Math.round(a*1.6094) +" "+ "kms.");
alert("hi");
}
}
// End -->
</script>


It has nothing to do with the tab panel. Calling a javascript function is the same no matter how many layers of control nesting there are. The problem is that you are missing a semicolon between "DoCalc()" and "return false". Use:

OnClientClick="DoCalc(); return false"
or
OnClientClick="DoCalc(); return false;"


I am geeting java script error "xyz is undefined"

xyz is a form which is declared inside tabpanel.


Hi,

May you try document.getElementById("xyz"), If xyz is runat server,use document.getElementById("<%=xyz.clientID%>").

Best Regards,

call webservce

Hi

i try to call a webservice when form load,but i can't

my code like

<form id="f" onload = "callService()>

<script language = "javascript">

function callServicce()

{..........}

</script>

</form>

please help me ??

thank you

You need to register your webservice using ScriptManager and ServiceReference.
Here are examples of the webservice and javascript code which calls the webservice. Method DoSearch is calling the webservice method

Webservice in (Webservice.asmx)

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService] //If this is not added, then it is not possible to generate javascript proxy.
public class MyWebService : System.Web.Services.WebService {

[WebMethod]
public string HelloWorld(string query)
{
string inputString = Server.HtmlEncode(query);
if (!String.IsNullOrEmpty(inputString))
{
return String.Format("Hello, you queried for {0}. The "
+ "current time is {1}", inputString, DateTime.Now);
}
else
{
return "The query string was null or empty";
}

}

}

JavaScript snippet:

<form id="Form1" runat="server">
<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference path="~/WebService.asmx" />
</Services>
</asp:ScriptManager>
<div>
Search for
<input id="SearchKey" type="text" />
<input id="SearchButton" type="button" value="Search"
onclick="DoSearch()" />
</div>
</form>
<hr style="width: 300px" />
<div>
<span id="Results"></span>
</div>

<script type="text/javascript">

function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");
MyWebService.HelloWorld(SrchElem.value, OnRequestComplete);
}

function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}

</script>

Hope this helps


thanks for your reply

but my question is how to call webservice on formload event ?

i already do what you show,but webservice could'n to be call on form load event


Ajax, your code looks fine. Perhaps you could post your entire script so we can debug further?
I think you could try ScriptManager1.RegisterClientScriptBlock method in Page_Load Event.

Saturday, March 24, 2012

CalenderExtender not working when TextBox is not empty

Hi

I was testing the CalendarExtender control and it worked fine but only if the TextBox was empty. I'm guessing this is a bug...! Does anyone know how to fix it?

Cheers

I hv d same problem

Calender

not working if applyinf the format to

Calender

<

cc2:CalendarExtenderID="CalendarExtender1"runat="server"PopupButtonID="Image1"TargetControlID="txtdob"Format="dd-MMM-yyyy"></cc2:CalendarExtender><asp:TextBoxID="txtdob"runat="server"></asp:TextBox><asp:ImageID="Image1"runat="server"ImageUrl="~/images/Calendar_scheduleHS.png"/>

and behind code

txtdob.Text = myDate.

ToString("dd-MMM-yyyy");

if txtdob is already filled during page load

Wednesday, March 21, 2012

CalendarExtender with a ModalPopupExtender and missing weekdays

Hi

I am trying to use a CalendarExtender inside a Panel being shown as a ModalPopup. The functionality is fine , however the calendar has cropped two days of it the week of a week meaning that I am only seeing fron Sunday till Thursday. How am I to fix this or work around it ?

<asp:LinkButton ID="LinkButton1" runat="server">Godkend</asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BackgroundCssClass="modalBackground" CancelControlID="Button2" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" style="display:none">
<div >
<fieldset>
<legend>Detajler</legend>
<asp:RadioButtonList ID="RadioButtonList2" runat="server">
<asp:ListItem Value="0" Selected="True">Alle</asp:ListItem>
<asp:ListItem Value="1" >Valgte</asp:ListItem>
</asp:RadioButtonList>


<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="2" Selected="True">Godkendt</asp:ListItem>
<asp:ListItem Value="1">Afvist</asp:ListItem>
<asp:ListItem Value="0">Afventer</asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="Label4" runat="server" Text="Dato"></asp:Label><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox2" >
</cc1:CalendarExtender>
</fieldset>
<div>
<asp:Button ID="Button1" runat="server" Text="Ok" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Cancel" />
</div>
</div>
</asp:Panel>

Regards

I copied your code and it worked just fine for me. What timezone are you in?


I copied your code and it worked just fine for me. What timezone are you in?


I copied your code and it worked just fine for me. What timezone are you in?

I

I copied your code and it worked just fine for me. What timezone are you in?

I know

I copied your code and it worked just fine for me. What timezone are you in?


...


DisturbedBuddha:

I copied your code and it worked just fine for me. What timezone are you in?

I am in CET +1h. I can see others having experienced this issue also. They have been able to work around with some CSS tricks , but I have not been able to.

http://forums.asp.net/p/1089990/1642856.aspx