|
That is excatly what I was looking for, Thank you very much dnh, but I think you have to use Parent.Page for the usercontrol and not this.Page, maybe that is just for my case but anyway thanks again
|
|
|
|
|
cullyk wrote: think you have to use Parent.Page for the usercontrol and not this.Page
hmm not really, Control.Page[^] property really points to aspx *page* where your user control is, on the other hand Parent points to control that directly contain your user control, e.g. if it is in Placeholder , Parent will be that placeholder. They both should have same Page ...
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Well I want to access Functions on the page that the user control is contained in. So if I have a page called Maintenance.aspx which contains a usercontrol now I want to access a function on maintance.aspx.vb from the usercontrol I would have the following code in the usercontrol server side:
Dim maintenance As Maintenance
maintenance = CType(Parent.Page, Maintenance)
maintenance.viewQuestions() 'where viewQuestions() is a public function contained on the main page
This works fine for me as is, yet I stand to be corrected, I am I missing something?
Sorry if I have not explained this properly
|
|
|
|
|
cullyk wrote: maintenance = CType(Parent.Page, Maintenance)
could be as well
maintenance = CType(Page, Maintenance)
It's just that you said you have to use Parent.Page.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
You can do this by Delegates and Events
|
|
|
|
|
My application needs Exports to Excel and From Excel to Database
for that ,i have used the code
For Export:
Dim mySQLCommand As New SqlCommand
Dim myConnection As New SqlConnection
Dim datagrid1 As New DataGrid
Dim DS As New DataSet
Dim DT As New DataSet
myConnection = New SqlConnection("Password=technologies;Persist Security Info=False;User ID=sa;Initial Catalog=Lims_Demo;Data Source=VISHWA") 'ConfigurationSettings.AppSettings("MyConStr"))
myConnection.Open()
Dim da As New SqlDataAdapter("SELECT top 30 ProductCode,ProductName,GenericName,RetestPeriod FROM Results where status=0", myConnection)
da.Fill(DT)
datagrid1.DataSource = DT
datagrid1.DataBind()
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New Html32TextWriter(tw)
datagrid1.RenderControl(hw)
Response.Write(tw.ToString())
Dim path As String = "C:\...\abc.doc"
Response.AddHeader("content-disposition", "attachment; filename=Worddocument.xls")
Response.End()
'FileStream sourceFile = new FileStream(path, FileMode.Open);
'long FileSize;
'FileSize = sourceFile.Length;
'byte[] getContent = new byte[(int)FileSize];
'sourceFile.Read(getContent, 0, (int)sourceFile.Length);
'sourceFile.Close();
'Response.BinaryWrite(getContent);
'dim SaveFileDialog1 as System.
'If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
' RichTextBox1.SaveFile(SaveFileDialog1.FileName, _
' RichTextBoxStreamType.PlainText)
'End If
myConnection.Close()
the above coding is working very good and giving the required results
but when i am going to Import Excel data to Database
I have used the code, which i found in Msdn help
'---------------------Importing Data From Excel to Database
If Not FILE1.PostedFile.FileName = "" Then
FilePath = FILE1.PostedFile.FileName
End If
'Excel Work Sheet Database Connection
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & FilePath & "; " & _
"Extended Properties=Excel 8.0;")
'Select the data from Sheet1 of the workbook.
'MyConnection.Open()
'Dim dt As Table = MyConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null)
Dim f As Array
f = Split(FilePath, "\")
Dim k As Integer = f.Length
Dim str As String = f(k - 1)
Dim filename As String = str.Substring(0, str.LastIndexOf("."))
'str.Split(".xls")
'Dim f1 As Array
'f1 = Split(str, ".")
'Dim str1 As String = f1(f1.Length - 1)
Try
Dim str2 As String = "select * from [EXPnIMP$]"
'Select the data from Sheet1 of the workbook.
'MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
' str2, MyConnection)
''' Select the data from Sheet1 of the workbook.
'MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
' "select * from [" & filename & "$]", MyConnection)
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"select * from [" & filename & "$]", MyConnection)
DS = New System.Data.DataSet 'DataSet
MyCommand.Fill(DS) 'Filling The dataset
------------------------------------------------------
it is also working fine,but it is working only for Excel sheet , which i create
it is not working for the excel sheet which i created by using the above code
it is giving the below error,
i think the errror may be in exporting to excel,
when i put google search,it is showing that, file should be exclusive,how can we set exclusive to a file
the error , i am getting is :
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access 97 Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.
kishore
|
|
|
|
|
After you export the data to the excel file close it and then try to export the data from excel to database.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Thanks Apurv
but Even Iam doing same thing what u said, it is giving same error
kishore
|
|
|
|
|
Hi Friends ,
I want to put the repeater control on my webpage , and want to develop the functionality for Editing and Deleting like datagrid .Is it possible to inser Edit and Delete Functionalities using repeater like datagrid?
If it is possible , please guide me
Thanks
param
|
|
|
|
|
i have placed an image in the datagrid bound columns as
e.Item.Cells(i).Text = ""
it will display an image "red.gif" in the bound column.
this will call a javascript fn, which will send two values to it. Its working fine. At the same time, when i click the bound column, i want to change the image to green.gif using javascript.
same like toggle button.
How to perform this, please its urgent.
Regards,
abul.
|
|
|
|
|
hello Technicals
This is ajay.
when i m trying to run(pressing F5) my web application in Asp.net, i get the following error
"Error while trying to run project.The project is not configured to be debugged.Unable to start debugging on the web server."
I have done a lot of brainstorming on it but unfortunately could not fix it.
I have followed a lot of forums including 'support.microsoft.com/kb/306156'
i am the member of debugger users group.And am loging through administrator.So i also have the enough rights.......
Any help regarding this...
I am very worried.
one thing more when i m going through Debug->Start without Debugging
then it works fine.
Is there any error in my web.config file or something else....
plz plz help
thanks in advance
Ajay
|
|
|
|
|
add this in your web.config under <system.web>.
<compilation debug="true" />
|
|
|
|
|
ya <compilation default="" language="vb" debug="true"> is inside <system.web>
|
|
|
|
|
do u have vs 2005 installed on ur machine?
Best Regards
3ala2
|
|
|
|
|
no no
not it all...
i have only 2003 version installed on my machine..
any suggetion
|
|
|
|
|
Hi.
i am facing same error in vs 2005.
unable to start debugging on the web server.debugging failed because integrated windows authentication is not enable.
some application ,which i convert from 1.1 to 2.0,its work fine but in vs 2005 i cant run with debug.
pathan
|
|
|
|
|
|
The "who" who is using the image is probably you the first time you uploaded. Make sure that you are properly disposing of objects that you use when dealing with the image. One of them must still be holding on to the image file.
I've done had this problem before when using a System.Drawing.Image object in my code to deal with a file. After you are done with it you must dispose it to get it to release it's hold on the file. This is my example:
Dim x as System.Drawing.Image<br />
x= Drawing.Image.FromFile(strMyImageFilePath)<br />
x.Dispose()
Hope this helps.
|
|
|
|
|
hi
try this code
public void OnUpload(Object sender, EventArgs e)
{
// Create a byte[] from the input file
int len = Upload.PostedFile.ContentLength;
byte[] pic = new byte[len];
Upload.PostedFile.InputStream.Read (pic, 0, len);
// Insert the image and comment into the database
SqlConnection connection = new
SqlConnection (@"server=INDIA\INDIA;database=iSense;uid=sa;pwd=india");
try
{
connection.Open ();
SqlCommand cmd = new SqlCommand ("insert into Image "
+ "(Picture, Comment) values (@pic, @text)", connection);
cmd.Parameters.Add ("@pic", pic);
cmd.Parameters.Add ("@text", Comment.Text);
cmd.ExecuteNonQuery ();
}
finally
{
connection.Close ();
}
}
and try
this link also
http://www.codeproject.com/aspnet/PicManager.asp
regards
saravanan
|
|
|
|
|
Hello,
I am working on a project and the client wants to change the font color to white and the bar itself to navy. Everything works fine, but the caret that goes along with any menuitem that has a submenu is still black. So here is the basic questions. I am using VS 2005, so .NET 2.0 is what the site is running.
Can the caret color be changed? If it is an image file, can the image be changed? Or if all else fails, can it be removed totally?
Thanks,
Leo
Leo T. Smith
|
|
|
|
|
Hi there,
This is the image stored in the web resource, however you can replace or remove it with a couple of properties of the Menu/MenuItem classes.
MenuItem.PopOutImageUrl Property [^]
|
|
|
|
|
Thanks, this helps a lot. I don't know how I managed to miss that attribute, but I did.
Leo T. Smith
|
|
|
|
|
Hello,
I have been looking around for a way to pass a custom object I created to hold a user's information across different pages. I'm trying using Server.Transfer(), but even though it gives me access to the sender's controls (like textboxes and the such), it doesn't allowe me to access the custom object I created.
So far I'm thinking in serializing the object to an XML string, so some bogus encrypting to the string and pass it as either a hidden input field or as part of the querystring.
Yet, I know there must be a better, more optimum way to do it. Can someone point me in the "right" direction?
Thanks in advance!
|
|
|
|
|
You should be able to put it in
HttpContext.Current.Items
or at the very least share it through the session.
Using the GridView is like trying to explain to someone else how to move a third person's hands in order to tie your shoelaces for you.
-Chris Maunder
|
|
|
|
|
If the object contains simple types, add the serializable attribute to the class and use a session to pass it throughout the session.
|
|
|
|