|
:(I have form1.aspx and code behind for this form (form1.aspx.cs). I have a UserControl (UserControl1.cs) that is built in a package dll that is included in the project. The DLL has been added as a reference.
What I am trying to do is access UserControl1's Set() method from within my code behind (form1.aspx.cs).
Here is an example of the set method in UserControl1.cs. FYI, I am not using the get() method at this time.
public string psField1
{
get { return __Field1; }
set { _Field1 = value; }
}
So, in form1's code behind, I assume I will have to instantiate UserControl1.cs first.
PackageControl.UserControl2.......
now I need the rest to access the set() method in UserControl1.cs to set
|
|
|
|
|
If the user control is in use on the page, then it should just be
myControl.psField1 = x;
if you don't have an instance of the control on the page, then why would you want to access the set method ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi guys,
i want to save and retieve images into sql server 2005. i have a table caled resourcephotos with the columns:
res_id(int) and res_photo(image).
i don't have problems with saving the images into the database...when a new image is saved, then u see in the res_photo column <binary data="">
bud when i want to select the image and set it to the picturebox i get the error: parameter is not valid
here some code of my app to retrieve image and set it into the picturebox:
SqlCommand cmd27 = new SqlCommand("SELECT Res_photo FROM ResourcePhotos WHERE Res_id = '" + res_id + "'", myconn);
byte[] b = (byte[])cmd27.ExecuteScalar();
MemoryStream myms = new MemoryStream(b);
Image img = _res.pictureBox1.Image;
img = Image.FromStream(myms); <--------------HERE has the error to do
_res.pictureBox1.Image = img;
i also tried Bitmap instead of Image, bud i got the same error.
does anyone any idea? thanx.
|
|
|
|
|
Djavid j wrote: <--------------HERE has the error to do
What error? You don't think we need to see the error message to help?
Do you know what the result of your SQL command is?
|
|
|
|
|
u can read the error clearly in my post...bud here again: the parameter is not valid
|
|
|
|
|
Djavid j wrote: u can read the error clearly in my post
My bad, I missed it.
That indicates that the data parameter you are giving to Image.FromStream() is not valid image data. I cannot determine why as there could be many reasons, here are a few:
The data is not stored in the database correctly
The query did not return a result
The code is not dealing with the query result correctly (casting it to a byte[]).
|
|
|
|
|
it's okay, thanx for the quick response.
i don't know wheater the image data is correctly saved, cause i see in the column res_photo only this: <binary data=""> . bud i know for sure that other data is correctly saved and the query returns also a result, i tested by resturning the res_id by a messagebox.
and whether the code is not dealing with the query result, i have no idea.
|
|
|
|
|
I think using ExecuteScalar() might be the problem, a byte[] might not be supported.
|
|
|
|
|
|
Hi, sorry if I have missed or not read all of your Tab Articles, but I never see a example of maybe doing the paste/copy command when a user is allowed to create their own tabs with text boxes in them. Since they are in a array under the name of newRtb it gets confusing how to allow the user to lets say paste information on a selected tab with a Rich Text Box in it.
Any suggestions on what to do? I do have code, but it does not work...
private void Cut(object sender, System.EventArgs e)
{
int index = this.Controls.IndexOfKey("newRtb");
if (index != -1)
{
Control control = this.Controls[index];
RichTextBox richTextBox = control as RichTextBox;
if (richTextBox != null)
{
richTextBox.Cut();
}
}
}
I am completely lost on how to do this and this is the only thing stopping me from finishing my program I made.
Thanks, Ajm113
-- modified at 12:04 Wednesday 10th October, 2007
|
|
|
|
|
Hi!
When I try to serialize a object that has a TimeSpan property that property is serialized as if it is null even if it was set.
Can anyone help me?
Thanks,
Lukas
|
|
|
|
|
Are you using the XmlSerializer? If so, then check this[^] out.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
|
See my reply to that thread.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi,
I have to following nagging problem. I have a normal form where i put at runtime a usercontrol. This usercontrol has a property called RE_ID. when adding the usercontrol to the form
<br />
usxClientDetail objControl = new usxClientDetail();<br />
objControl.Dock = DockStyle.Fill;<br />
this.tabPage1.Controls.Add(objControl);<br />
<br />
i would like to call that property so the usercontrol gets filled with the correct data. But there is no way i can access that
<br />
<br />
foreach (UserControl ctrl in tabPage1.Controls)<br />
{<br />
if (ctrl.Name == "usxClientDetail")<br />
{<br />
foreach (Control ct in ctrl.Controls)<br />
{<br />
MessageBox.Show(ct.Name.ToString());<br />
}<br />
}<br />
}<br />
i can loop through everything but not through the propertycollection. At least it seams ...
any ideas suggestions how to access that public property on the form at runtime is welcome :->
Kind regards,
Marcel Vreuls
http://www.marcelvreuls.com
< >
|
|
|
|
|
You can use the "is" keyword and cast it to the appropriate type, like so:
foreach (UserControl ctrl in tabPage1.Controls) {
if (ctrl is usxClientDetail) {
usxClientDetail clientDetail = ctrl as usxClientDetail;
}
}
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thanks that works. I costed me 2 hours today en asking at CP 5 minutes ..
again thnx.....
Kind regards,
Marcel Vreuls
http://www.marcelvreuls.com
< >
|
|
|
|
|
Hi friends
I wrote follow code to send an image in network:
<br />
BinaryWriter myBR = new BinaryWriter(MyNetworkStream);<br />
myPic.Save(MyMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);<br />
byte[] arrImage;<br />
arrImage = MyMemoryStream.GetBuffer();<br />
myBR.Write(arrImage);<br />
And this for receive it:
<br />
MemoryStream memstr = new MemoryStream();<br />
byte pic;<br />
BinaryReader br = new BinaryReader(myNetworkStream);<br />
bool loop = true;<br />
while (loop)<br />
{<br />
try<br />
{<br />
pic= br.ReadByte();<br />
memstr.WriteByte(part);<br />
}<br />
finally<br />
{<br />
loop = false;<br />
}<br />
}<br />
byte[] picture = memstr.GetBuffer();<br />
but in receive part, when it arrive to "pic = br.ReadByte();", it do no thing and there is no error.
can you tell me what is incorrect code?
|
|
|
|
|
Maybe I'm not understanding your problem, but why are you using a binary reader? Just use myNetworkStream.ReadByte()
|
|
|
|
|
An array of bytes is not represented the same way as individual bytes by the BinaryWriter. You can't write the data as an array and read it as individual bytes.
Why are you using a BinaryWriter and BinaryReader at all? Why not write and read the data directly?
---
single minded; short sighted; long gone;
|
|
|
|
|
Your loop existsexits on the first loop every time. Finally is always executed after a try block. What you intended was likely catch{loop = false;} but you need a different understanding of streams, instead.
byte[] bytes = new byte[255;]
while((bytesRead = stream.ReadBytes(bytes, 0, bytes.Length)) != 0)
otherStream.Write(bytes, 0, bytesRead);
is a better construct for copying a stream to another. (255 is arbitrary)
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Dear gurus,
is it possible to download the complete net-framework-3.0-sdk from anywhere (e.g. as a zip-file)?
If I try to download it from micrsoft, than I only get a small "setup.exe". This one seems to start some downloads by itself in background during installation.
In advance:
Thanks for your advices
|
|
|
|
|
On this[^] page under Instructions you can download the redistributable packages that contains the entire framework instead of just a bootstrapper.
|
|
|
|
|
Thanks for your help!
The site you recommended contains only the redistributable package. It is not the complete SDK.
Is there also any site?
Thanks !
|
|
|
|
|
Here?[^] Click the "Continue" button next to "validation required" and a DVD image file will become available for download in the Instructions section - if your Windows validates properly. Is that what you're looking for?
|
|
|
|