|
Generally, the advantage of WebService is that you can plug in multiple clients - Web interface, WinForms client etc. to the web service, and those clients don't need to have any knowledge about the database itself. Also, it is more maintainable, if anything changes on the db level, you need to change only the webservice, not every client.
Another point is a security, if you are accessing the database from WinForms client, anyone can reverse engineer the client app and see connection string or username/password combination. When you keep this information on the web service, only privileged users (users with log-on access to the server) can have possible access to this information.
However, if your scenario is restricted to ASP.NET application -> WebService -> DB server structure, I don't really see the point having the WebService, especially if the WebServer and the WebService are running on the same machine.
I would say you should build data access layer within your web application then.
Pilo
|
|
|
|
|
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test1", "function CreatePopUP(url,popArguments ,titleStr){if(popArguments == null || popArguments == "") {popArguments = "dialogWidth:30;dialogHeight:25;help:no;status:no;resizable:yes;";PopReturnedValue = false;};PopReturnedValue = showModalDialog("default2.aspx");", true);
what is the error in this code? it has syntax error. does anybody know
|
|
|
|
|
{popArguments = "dialogWidth:30;
The " closes the " started at "function CreatePopUP
Try change to ' instead.
- Reelix
|
|
|
|
|
replace your " with \" in the javascript string, or use ' instead
|
|
|
|
|
i use this code in my form:
cell8.Controls.Add(new LiteralControl("<A HREF=" + "javascript:window.open('a.htm')" + " <span style=" + "font-size:9pt;" + "></span>Print</A>"));
where should be my page a.htm my mean is what is the path format. what should i write in window.open(????), my page a.htm is in this path : C:\webpart\WritingWebPart\Reservation
|
|
|
|
|
You can't use physical path, unless you want to use your web application only for yourself on your local computer. (Other users probably don't have the file on the same physical path)
If you have the a.htm file in the same folder as the file that contains the code above, then use just window.open('a.htm')
if not, then you still can use relative path, for example window.open('SubFolder/a.htm') or window.open('../a.htm')
THIS IS PREFERED WAY!
or if you know what is going to be the url of the a.htm, then use it:
window.open('www.myserver.com/myApp/a.htm')
Note that url shouldn't be hardcoded, but should be determined in runtime (as zour application might be deplozed on more than one server, or the server name can be changed)
Pilo
|
|
|
|
|
hey any one please help in acessing acessing labletext which is in grid view cell.
|
|
|
|
|
GridView1.Rows[1].Cells[1].Text;
ti will give you second cell's text of second row
I Love T-SQL
|
|
|
|
|
Or store the label as template field and use find control to find it
Using specific cells is a problem if you need to move columns about as you will then need to change the reference code to reference the correct cell
|
|
|
|
|
I agree with you, I just gived an idea how to get cell's text.
I Love T-SQL
|
|
|
|
|
All,
I am getting follwing error while reading my XML file directly returned from web service. This occurs normally when XML have some misplaced node, but my XML is returned from webservice with few chances to have node errors.
Can any one help me regarding this problem.
My error page is:
Server Error in '/portal' Application.--------------------------------------------------------------------------------
This is an unexpected token. The expected token is 'NAME'. Line 778, position 626.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: This is an unexpected token. The expected token is 'NAME'. Line 778, position 626.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
And my stack trace is:
[XmlException: This is an unexpected token. The expected token is 'NAME'. Line 778, position 626.]<br />
System.Xml.XmlTextReader.SetAttributeValues() +323<br />
System.Xml.XmlTextReader.ParseElement() +138<br />
System.Xml.XmlTextReader.Read() +94<br />
System.Xml.XmlValidatingReader.ReadNoCollectTextToken() +38<br />
System.Xml.XmlValidatingReader.Read() +14<br />
System.Xml.XmlLoader.LoadCurrentNode() +612<br />
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +49<br />
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +102<br />
System.Xml.XmlDocument.Load(XmlReader reader) +72<br />
System.Xml.XmlDocument.LoadXml(String xml) +163<br />
AI.Portal.Web.UI.RailBooking.ProcessGet()<br />
AI.Portal.Web.UI.BaseDialog.ProcessRequest()<br />
AI.Portal.Web.UI.HttpHandler.ProcessRequest(HttpContext context)<br />
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179<br />
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
I am using Microsoft .NET Framework Version:1.1.4322.2407; ASP.NET Version:1.1.4322.2407 Thanks in advance for any help.
Anand
Anand Desai
Developer
Atharva Infotech
modified on Tuesday, April 22, 2008 8:23 AM
|
|
|
|
|
and what is the token on line 778, position 626?
|
|
|
|
|
hi friends
i m using updatepanel for gridview..
i stuck with one problem.
The problem is
In my update panel i m using two button
one is imagebutton is a part of gridview &
othe is save button to save the grid...
Now when i click on that button first it call the Page_load and then the related buttonclick event....
i want that at page load can i know which button is clicked so that i call that function...
Plz tell me...
thanks
|
|
|
|
|
Why don't you call that function in the Button event itself ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
hi sandip
actually when i click on button that time first page load event is called and i just lost my dat in grid which i want to save
|
|
|
|
|
Are you adding GridView dynamically ?
Is ViewState Enable in your page ?
Let me know the details what are you trying in GridView and how you implemeneted it ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
yes i m creating it dynamically and i have two button one is to add new row and one is to save the rows from grid to database
and yes my grid viewstate is enabled
thanks
|
|
|
|
|
Add Grid View in Page_init method instead of Page Init
i think you are adding Grid view in page load ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
hey sandeep
when i add grid on page init it do not generate new row inside grid
|
|
|
|
|
hey sandip this is my
.aspx page
]]>
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>Untitled Page
function setHidVal(val)
{
debugger;
var ob=document.getElementById('tshf');
if(val=='Save')
{
ob.value=val;
}
else if(val=='AddRow')
{
ob.value=val;
}
}
<asp:scriptmanager id="ScriptManager1" runat="server">
AsyncPostBackTimeout="360"/>
<asp:label id="lblmy" runat="server">
<asp:updatepanel id="UpdatePanel1" runat="server">
<contenttemplate>
<asp:hiddenfield runat="server" id="tshf" value="">
<asp:gridview id="grdnew" runat="server" enableviewstate="true">
Style="z-index: 100; left: 53px; position: absolute;top: 81px"
CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="false">
<footerstyle backcolor="#990000" font-bold="True" forecolor="White">
<rowstyle backcolor="#FFFBD6" forecolor="#333333">
<selectedrowstyle backcolor="#FFCC66" font-bold="True" forecolor="Navy">
<pagerstyle backcolor="#FFCC66" forecolor="#333333" horizontalalign="Center">
<headerstyle backcolor="#990000" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White">
<columns><asp:templatefield>
<headertemplate>
<asp:label id="lblimg" runat="server" text=" ">
<itemtemplate>
<asp:imagebutton id="btnimgadd" runat="server" imageurl="~/add.gif">
ToolTip="Add Row" OnClick="bUpdate1_Click"
OnClientClick="javascript:setHidVal('AddRow');" />
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label1" runat="server" text="Name">
<itemtemplate>
<asp:textbox id="TextBox1" runat="server">
EnableViewState="true" Text='<%# Eval("Name")%>' Width ="100px" />
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label2" runat="server" text="ContactNo">
<itemtemplate>
<asp:textbox id="TextBox2" runat="server">
EnableViewState="true" Text='<%# Eval("contactNo")%>' Width ="100px" />
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label3" runat="server" text="Email">
<itemtemplate>
<asp:textbox id="TextBox3" runat="server">
EnableViewState="true" Text='<%# Eval("email")%>' Width ="100px"/>
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label4" runat="server" text="Designation">
<itemtemplate>
<asp:dropdownlist runat="server">
DataTextField="DesignationName" DataValueField="pkDesignationID"
EnableViewState="true" ID="ddldesg" Width="100px">
<asp:textbox id="TextBox4" runat="server">
EnableViewState="true" Text='<%# Eval("designation")%>'
Width ="100px" Visible="false"/>
--%>]]>
<asp:button id="btnSave" runat="server" text="Save" onclick="btnSave_Click">
OnClientClick="javascript:setHidVal('Save');" />
<triggers>--%>]]>
<asp:asyncpostbacktrigger controlid="btnSave" eventname="Click">
<asp:updateprogress id="UpdateProgress1" runat="server">
AssociatedUpdatePanelID="UpdatePanel1">
<progresstemplate>
Getting Data From Server.....
|
|
|
|
|
You are not adding the GridView Dynamically to the Page
So don't get confused with my last posts
Now from my understanding you are adding rows using javascript and you want this added row at server side along with data ...
Let me tell you you are doing in wrong way
Javascript will add row at client side server don't anything what javascript is doing in client browser
Check this URL
http://gridviewguy.com/CategoryDetails.aspx?categoryID=7[^]
Or as you are uaing AJAX why dont you add line at server side
Search for it in google
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Sandeep actually i m using update panel and script manager for grid view
i m using javascript for only change the value of hiddenfield at the time when i click on that button.
then on page load i m checking the value of hiddenfield and call related function
can u tell where i m wrong
thanks
|
|
|
|
|
this is my aspx.cs page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using MySql.Data.MySqlClient;
public partial class Default2 : System.Web.UI.Page
{
DataSet ds;
MySqlConnection mcon;
MySqlCommand mcmd;
MySqlDataAdapter mda;
DataTable dt;
DataRow dr;
protected void Page_Init(object sender, EventArgs e)
{
mcon = new MySqlConnection("Database=tsmdemo;Server= 172.16.1.22;uid=root;pwd=tops123;");
mcon.Open();
if(!IsPostBack)
{
btnAddRow();
btnAddRow();
fillddl();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
if (tshf.Value == "Save")
{
lblmy.Text = grdnew.Rows.Count.ToString();
savedata();
tshf.Value = "";
}
else if (tshf.Value == "AddRow")
{
lblmy.Text = grdnew.Rows.Count.ToString();
btnAddRow();
fillddl();
tshf.Value = "";
}
}
}
protected void btnAddRow()
{
dt = CreateDataTable();
grdnew.DataSource = dt;
grdnew.DataBind();
Session["TimeSheet"] = "AddNew";
}
protected void btnDisRow()
{
dt = (DataTable)ViewState["DataTable"];
grdnew.DataSource = dt;
grdnew.DataBind();
}
protected DataTable CreateDataTable()
{
DataTable dtvalues = (DataTable)ViewState["DataTable"];
if (dtvalues == null)
{
dtvalues = new DataTable();
dtvalues.Columns.Add(new DataColumn("", typeof(string)));
dtvalues.Columns.Add(new DataColumn("Name", typeof(string)));
dtvalues.Columns.Add(new DataColumn("contactNo", typeof(string)));
dtvalues.Columns.Add(new DataColumn("email", typeof(string)));
dtvalues.Columns.Add(new DataColumn("designation", typeof(string)));
ViewState["DataTable"] = dtvalues;
}
else
{
dr = dtvalues.NewRow();
dtvalues.Rows.Add(dr);
ViewState["DataTable"] = dtvalues;
}
return dtvalues;
}
protected void fillddl()
{
try
{
mcmd = new MySqlCommand("Select * from tbldesignation;", mcon);
mda = new MySqlDataAdapter(mcmd);
ds = new DataSet();
mda.Fill(ds);
if ((String)Session["TimeSheet"] == "AddNew")
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow row in grdnew.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl("ddldesg");
ddl.DataSource = ds;
ddl.DataBind();
}
}
if ((String)Session["TimeSheet"] == "Getdata")
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow row in grdnew.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl("ddldesg");
ddl.DataSource = ds;
ddl.DataBind();
TextBox temp = (TextBox)row.FindControl("Textbox4");
ddl.SelectedIndex = Convert.ToInt32(temp.Text);
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
ds.Dispose();
mda.Dispose();
mcmd.Dispose();
}
}
protected void savedata()
{
string cmdText;
try
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow gdr in grdnew.Rows)
{
string name = ((TextBox)gdr.FindControl("TextBox1")).Text;
string contactNo = ((TextBox)gdr.FindControl("TextBox2")).Text;
string email = ((TextBox)gdr.FindControl("TextBox3")).Text;
int designation = ((DropDownList)gdr.FindControl("ddldesg")).SelectedIndex;
cmdText = "INSERT INTO tblempinfo VALUES ('"
+ name + "','" + contactNo + "','" + email + "'," + Convert.ToString(designation + 1) + ")";
mcmd = new MySqlCommand(cmdText, mcon);
mcmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
mcmd.Dispose();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
}
protected void bUpdate1_Click(object sender, EventArgs e)
{
}
}
|
|
|
|
|
Ankit i can't check what is going wrong with this
Try to debug the things and see wats happening
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Just run an event for each button then you will know which one has been selected
|
|
|
|