AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Ajax_ModalPopup_PostBack_GridView.aspx
Posted by Sivaprakas on  3/27/2008 10:11:15 PM Category: AJAX
Add to my favorites
Email to friend
hi i try this article
http://www.aspdotnetcodes.com/Ajax_ModalPopup_PostBack_GridView.aspx
but i got the javascript error
'WebService is undefined' how to solve this

Post Your Reply Post New Question

 Viewer's Reply
Webservice path
Answered By Moderator1 on 3/28/2008 8:51:15 PM
Hi,

This error might come if your webservice is not pointed correctly in the ScriptManager Tag. Make sure the webservice exists in the path you mentioned in the ServiceReference Path property.

<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>
 
Ajax_ModalPopup_PostBack_GridView.aspx
Answered By Sivaprakas on 3/31/2008 9:55:29 PM
hi Moderator1 i verified i give the correct path and the webservice working perfectly i think the error in javascript code
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="http://localhost/afterTest2/WebService.asmx" />
</Services>
</asp:ScriptManager>

my javascript code


<script language="javascript" >
function ShowMyModalPopup(user_id)
{
var modal = $find('ModalPopupExtender1');
modal.show();
WebService.FetchOneCustomer(user_id,DisplayResult);

}

function DisplayResult(result)
{

var doc;
if (window.ActiveXObject)
{
doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async="false";
doc.loadXML(result);
}
else
{
var parser=new DOMParser();
var doc=parser.parseFromString(result,"text/xml");
}

var root=doc.documentElement.childNodes;
var tags;

for(var i=0;i<root.length;i++)
{
if (root[i].nodeType==1)
{
tags=root[i].childNodes;
}
}

for(var i=0;i<tags.length;i++)
{
if (tags[i].nodeType==1)
{
var xmlvalue=tags[i].childNodes[0].nodeValue;

switch (tags[i].nodeName)
{
case "user_id":
var label=document.getElementById('lblCode');
label.innerHTML=xmlvalue;
document.getElementById('hidCusCode').value=xmlvalue;
break;
case "name":
document.getElementById('txtName').value=xmlvalue;
break;
case "username":
document.getElementById('txtUserName').value=xmlvalue;
break;
case "password":
document.getElementById('txtPassword').value=xmlvalue;
break;

}
}
}
}


function HideModalPopup()
{
var modal = $find('ModalPopupExtender1');
modal.hide();
}


</script>


ASPX PAGE CODE


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=PS-FTPMAIL\PSINVENTORY;Initial Catalog=Service;User ID=sa;Password=password" SelectCommand="select * from user_table"></asp:SqlDataSource>
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" DataKeyNames="user_id" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="edit" Text="Edit" runat="server" > </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="username" HeaderText="UserName" />
<asp:BoundField DataField="password" HeaderText="Password" />
</Columns>
</asp:GridView>
<asp:Panel ID="modalPanel" runat="server" BackColor="LightGray" Height="269px" Width="428px" style="display:none">
User # : <asp:Label ID="lblCode" runat="server" Text="Label"></asp:Label> <asp:HiddenField ID="hidCusCode" runat="server" /> <br/>
Name: <asp:TextBox ID="txtName" runat="server"></asp:TextBox><br/>
UserName:<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><br/>
Password:<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox><br/>
<asp:Button ID="Button6" runat="server" Text="Update" OnClick="Button6_Click" />
<asp:Button ID="Button7" runat="server" Text="Cancel" />
</asp:Panel>
<cc1:ModalPopupExtender PopupControlID="modalPanel" TargetControlID="modalPanel" ID="ModalPopupExtender1" OnCancelScript="HideModalPopup()" CancelControlID="Button7" runat="server">
</cc1:ModalPopupExtender>


ASPX.CS CODE

if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton Link1 = (LinkButton)e.Row.FindControl("edit");
Link1.Attributes.Add("onclick", "ShowMyModalPopup('" + GridView1.DataKeys[e.Row.RowIndex].Value + "')");
}
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Building a Web Application Security Program
When Good HTML Goes Bad: How You Can Protect Your Web Applications
Web Application Security — How to Minimize Prevalent Risk of Attacks