|
|
Hello,
I am trying to import gmail and yahoo contacts in my asp.net website. i m using OpenContactsNet.dll and using following code
GmailExtract extractor = new GmailExtract();
NetworkCredential nc = new NetworkCredential(txtUserName.Text, txtPassword.Text);
bool res = extractor.Extract(nc, out list);
But this code is'nt working. I got false responseFrown
what could be the reason??
The .Extract function gives the following error when executes the line of code
HttpWebResponse exportResponse = (HttpWebResponse)contactsRequest.GetResponse();
Error: The remote server returned an error: (401) Unauthorized
Please help me in this regard as i have tried every thing. I place the app on www root but still no luck.. plzz help
|
|
|
|
|
I found following link very useful to do the same..
http://forums.asp.net/t/1144790.aspx[^]
In above link you will also find information regarding OpenContactsNet.dll and use of it.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
After implementing a CSS template to my web site i am getting the following error while running. "Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. "
I searched a lot in net and found some solutions which did not worked for me. But my actual problem is the same code is working in another browser. I am getting the error while i am using IE. What is the reason and solution???
|
|
|
|
|
Hi
I need an editable gridview for ASP.NET MVC 2.0
Can anybody help me?
Thank you
|
|
|
|
|
|
Actually I need editable grid view for mvc 2.0, not for dynamic database
|
|
|
|
|
i have to write a code for
for copying a selected data from excel sheet to data grid
now i m confused that whether i have to open the excel sheet with the program of had to show it to the form because i can't show the whole sheet to the datagrid (as its a requirement of a program) and after opening the sheet how i can copy the data from excel sheet display it on the datagrid
any ideas ??????
|
|
|
|
|
Use this function
public static DataTable getDataTable(string strFilename)
{
string SQL = "select * from [Sheet1$]";
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strFilename + ";";
connectionString += @"Extended Properties=""Excel 12.0;HDR=YES;""";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand(SQL, conn);
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
da.Dispose();
conn.Dispose();
cmd.Dispose();
return dt;
}
|
|
|
|
|
thnx for ur reply
but
it is simply the binding of excel sheet to datagrid
but i have to copy selected data from excel sheet
means when user click on certain record in excel sheet it gets copied in datagrid
okzzz
and plz do tell me also that how to open excel sheet with program for copying the data from it
thnx in advance
|
|
|
|
|
sorry i never do this so no idea.
|
|
|
|
|
i have one datalist and i have taken textbox in headerTemplate of DataList.
i want to get value of that TextBox in Button_click() which is outside of Datalist,
i have used foreach loop for getting textbox value but i m not able to get
so plz help me
|
|
|
|
|
Hai I have a problem while working with calender control.
****If i have selected from date from calender1 as friday and to date from calender2 as monday, calculated the difference between these days by using timespan.
but my problem is friday to monday should come for two days by excluding weekends.
plz reply.
|
|
|
|
|
Dear friends, I am uploading Excel sheet data using FileUpload control and want to store the data into sql server 2005 database. Excel Sheet file name is same as Table name in Database and Column headings are same as columns in database table. In my machine, I don't have MS Office. I am using OpenOffice now. I am getting an error "The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly." . I have written the following complete code. Please help me. Its very urgent. Please please please. The code is
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
SqlConnection connection=new SqlConnection("data source=10.0.3.30;initial catalog=rambasedev;user id=sa;password=admin");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
{
Boolean fileOK = false;
String path = Server.MapPath("~/UploadedFiles/");
if (FileUpload1.HasFile)
{
String fileExtension =
System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
String[] allowedExtensions = { ".xls", ".xlsx" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
}
}
}
if (fileOK)
{
try
{
string xConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath(FileUpload1.FileName) + ";" + "Extended Properties=Excel 8.0;";
using (OleDbConnection connection = new OleDbConnection(xConnStr))
{
OleDbCommand command = new OleDbCommand("Select EMPNO,ENAME,BASIC FROM [Sheet1$]", connection);
connection.Open();
// Create DbDataReader to Data Worksheet
using (OleDbDataReader dr = command.ExecuteReader())
{
// SQL Server Connection String
string sqlConnectionString = "Data Source=10.0.3.30;Initial Catalog=RambaseDev;Integrated Security=True";
// Bulk Copy to SQL Server
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.DestinationTableName = "SamplePS";
bulkCopy.WriteToServer(dr);
}
}
}
}
catch (Exception ex)
{
Success.Text = "File could not be uploaded.";
}
}
else
{
Success.Text = "Cannot accept files of this type.";
}
}
}
}
Please help me.
Regards,
Dileep
|
|
|
|
|
For .xlsx files I think u will need another connection string
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=filename.xlsx;Extended Properties=Excel 12.0;
u can also Add HDR property to connection string
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=filename.xlsx;Extended Properties=Excel 12.0;HDR=YES;
HDR=YES --> implies that the file has header info in the 1st Row
Try this let me know if it works or not
Tej Aj,
http://opexsolution.com/forum/[^]
|
|
|
|
|
Dear Tej,
I have tried Provider=Microsoft.ACE.OLEDB.12.0;Data Source=filename.xlsx;Extended Properties=Excel 12.0; for .xlsx files. I am getting the following error. Please help me...
ex = {"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."}
Regards,
Dileep
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
HtmlGenericControl div = (HtmlGenericControl)Page.FindControl("mydiv");
if (div != null)
{
div.InnerHtml = "test message";
}
}
i used this code, but not working? is there any solution? i search google but cant get relevant answer. please help me.
|
|
|
|
|
The obvious question is why not add the runat attribute?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
if i did add runat="server" i can access mydiv.innerText from .cs page.
please let me know if any way to access that.
|
|
|
|
|
When you add a runat=server attribute to an html element it is automatically wrapped as a HtmlGenericControl. Your first attempt gained you nothing.
So rather than this
HtmlGenericControl div = (HtmlGenericControl)Page.FindControl("mydiv");
if (div != null)
{
div.InnerHtml = "test message";
}
You could have this
div.InnerText = "test message";
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
when i add runat="server" no need to access via
HtmlGenericControl div = (HtmlGenericControl)this.FindControl("mydiv");
please check this image[^]
thank you for your time.
|
|
|
|
|
You can not access a Div without add runar="server" in code behind.
But you can get input element without add runar="server" like this:
in code behind
string pName = Request.Form['pName'];
|
|
|
|
|
Hello!
Is there an example project for ASP.NET www.codeproject.som. In which would be implemented to work with the database, loginizatsiya user, and work with the sessions. It is possible, and other functions, but the main three.
|
|
|
|
|
Hello,
I have created many user controls with custom properties, methods, etc. to help interact between my business layer and presentation layer. I have also developed a custom page class that is derived from the base Page class. Everything works well if I create my aspx pages statically and by this I mean insert the markup directly into the aspx pages source.
I had an idea to try and make my application more user friendly and have my pages source come from xml files defined by the end user. Since all of my custom server controls are in a single assembly, I figured I could use reflection to create the controls and insert them into the page. I have the code for this written, however, when I add the controls to the page (using reflection), I cannot access the base page class from within my custom controls.
Example.
I have a base page called UIBase dereived from System.Web.UI.Page.
I have a server control that is derived from System.Web.UI.Control. Within my custom control, I have a property that returns the controls page cast as the UIBase (which ALL of my pages within the site are set as via web.config)
public readonly property CtlPage() as UIBase
Get
Return ctype(me.page,UIBase)
End Get
end property
When I use reflection, I get an error within the return statement above. Unable to cast webform3_aspx as UIBase. I can dynamically add the controls via the page_init and add them to the page with no problem. This error only happens when reflection is used....
Also note that the UIBase class is in the same assembly as all other controls. Could this be the problem?
Here is my code that uses reflection to add the controls to the page.
Dim ctlAssem As System.Reflection.Assembly
Dim an As System.Reflection.AssemblyName = New System.Reflection.AssemblyName("MyWeb.Web.UI.Controlls")
an.CodeBase = "MyWeb.Web.UI.Controlls.dll"
ctlAssem = System.Reflection.Assembly.LoadFile("../../MyWeb.Web.UI.Controls.dll") 'shortened for readability
Private Sub initControls()
Dim mst As uibasepage_master = Page.Master
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(Server.MapPath("~/page_source/Employee.xml"))
Dim root As XmlNode = xmlDoc.DocumentElement
createControls(root, mst.BodyContent)
End Sub
Private Sub createControls(ByRef parentNode As XmlNode, ByRef parentCtl As Control)
If parentNode.ChildNodes.Count > 0 Then
For Each childNode As XmlNode In parentNode.ChildNodes
Dim ctlType As Type = ctlAssem.GetType("MyWeb.Web.UI.Controls." & childNode.Name)
Dim ctl As Control = Activator.CreateInstance(ctlType)
For Each ctlAttr As XmlAttribute In childNode.Attributes
Dim pi As System.Reflection.PropertyInfo = ctlType.GetProperty(ctlAttr.Name)
If pi.PropertyType Is GetType(String) Then
pi.SetValue(ctl, ctlAttr.Value, Nothing)
ElseIf pi.PropertyType Is GetType(Boolean) Then
If ctlAttr.Value.ToString.ToLower = "true" Then
pi.SetValue(ctl, True, Nothing)
Else
pi.SetValue(ctl, False, Nothing)
End If
End If
Next
parentCtl.Controls.Add(ctl)
If childNode.HasChildNodes Then
createControls(childNode, ctl)
End If
Next
End If
End Sub
Thanks to anyone that can help. This has drove me nuts for a few days now.
|
|
|
|