|
This wont really work unless u have only the 3 text boxes (other controls welcome)in question on the form I was just trying to point out that u will get a cast exception if you dont check the type. I would definately go with the other option.
Assigned for all 3 ontextchanged events. Obviously, you will need some reset code as well.
if (tb1.Text == "" || tb2.Text == "" || tb3.Text == "" ) validate = false;
Or place the 3 textboxes in a panel
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Does anyone have a working example of a WebControl that supports DataBinding via its DataSource property.
I've tried the MS example and it doesn't work - cut&paste+compile.
I was also offered some code from an MS representitive on a newsgroup but even though it all works during design time it doesn't set the DataSource property at Runtime - I am assuming its missing a final step but I can't see what it could be.
MS example[^]
Google news thread[^]
I would also like to add a DataMember using the DataMemberConverter as well (and some DataFields using the DataFieldConverter for good measure) At the moment my code works fine but I can't bind to it nicely via the properties window.
Thanks
Shaun
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Just a thought; but when you tried the code he gave what was the assembly's filename?
It is important that the second part of this attribute Designer("DataSourceControl.MyDataDesigner,DataSourceControl") gives the name of the assembly it is defined in.
Whenever you see something declared as "Namespace.TypeName, AnotherName" you can probably assume that 'AnotherName' is supposed to be the name of the assembly (without the .DLL or .EXE).
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
I changed that line so that it matched my assembly name - as I said the designer works at design time - its just that the DataSource doesn't get bound to the dataset at runtime eventhough it is marked to so so in the HTML DataSource="<%# dsLanguages1 %>
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Ok, I see now that when I replied I thought the copy/paste+compile was for the code he gave you; not the example
I have zero experience in creating web controls and databinding so that was the only thing I could offer
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
actually it was for both - examples should be in straight from the tin format or it should be noted where changes should be made - I had to spend time to get them to work - it would have been easier if he has used typeof - instead of strings as it would be easier to see the errors. In the end I only had to change the designer lines in both examples - but still no dice - glad for you input though
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
sorted it - I overrode DataBind and didn't call the base class version - apparently it is the Base class implementaion that causes all the properties to be read in properly
public override void DataBind()
{
base.DataBind();
myControl.DataBind();
}
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
1)What is the command to read int, double or other variables using microsoft
Library?
2)Anyone got good source codes(c#) for doing interactive forum using C#?
3) Any links to make good forum/messageboards using C#?
Thanks
Beginner
Vivian
|
|
|
|
|
beginner_vivian wrote:
3) Any links to make good forum/messageboards using C#?
http://www.codeproject.com/script/comments/forums.asp?forumid=1649[^]
beginner_vivian wrote:
1)What is the command to read int, double or other variables using microsoft
Library?
Can you expand?
beginner_vivian wrote:
2)Anyone got good source codes(c#) for doing interactive forum using C#?
I'm still looking too...
|
|
|
|
|
beginner_vivian wrote:
What is the command to read int, double or other variables using microsoft
Library?
Reading from where?
If you mean from the command line use Console.ReadLine to get a string representing what was typed (excluding the new line character(s)).
Then use the Convert classes to convert them to the type your are looking
for (you may have to parse the string to ensure it is what you think it is).
beginner_vivian wrote:
Anyone got good source codes(c#) for doing interactive forum using C#?
You mean a forum that is written with C# and that you can use on your website?
Microsoft has released the source to its ASP.NET forums[^], oddly enough on the ASP.NET forums page.
beginner_vivian wrote:
Any links to make good forum/messageboards using C#?
Just the one above
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
ASP.NET forums
Nice link .
|
|
|
|
|
I am using Datagrid. In some columns I used comboboxxes and in rest textboxes by handling events . That meant I am placing the combobox ot text box on mouse click to appropriate cell.Here I want to avoid sorting.But even if I set allowsort property to false if not works.What can be the possible problem ?
VikramVS
|
|
|
|
|
Hey all - I'm trying to get an RSS feed using the System.Net.WebRequest class:
<br />
<br />
WebRequest requ = WebRequest.Create(feed);<br />
Stream instream;<br />
WebResponse result = requ.GetResponse();<br />
instream = result.GetResponseStream();<br />
StreamReader reader = new StreamReader(instream);<br />
String code="";<br />
while(code != null){
code+=reader.ReadLine();<br />
}<br />
Unfortunately, it is hanging in my loop that retrieves all the text from the URL. Is there a better way to read all the text out of a feed? Also, does anyone know why it is an endless loop?
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
How is code ever going to be null if you're adding to it all the time?
You have to read into a temporary string, check for null and if it's not then add it to code. Alternatively, replace the entire loop with code = reader.ReadToEnd() .
Paul
|
|
|
|
|
As usual, I find an answer for everything I post for in moments. The StreamReader has a ReadToEnd method that can be used to get the entire contents of an InputStream.
I guess I'll leave my original post in case anyone else runs into something similar.
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
ARGGH! I just saw my original mistake. Sometimes I'm such a lame programmer.
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
I've been trying to write a managed interface for IActiveDesktop so I can use it to change the desktop wallpaper from a C# program. My source as it is at the moment is shown below. When I try and use any of the methods in the IActiveDesktop interface I get exceptions being thrown, mostly System.NullReferenceException but sometimes System.ArgumentException. I suspect something is wrong with my managed interface, but I'm not sure what. I've played around with changing the marshalling, but haven't hit on the answer yet. Any help would be greatly appreciated. I know there are easier ways to change the wallpaper, but I'm determined to figure this thing out now!
Thanks
----------------------------
using System;
using System.Runtime.InteropServices;
namespace ShellTypeLib
{
// Component structures for IActiveDeskTop
[StructLayout(LayoutKind.Sequential)]
struct COMPONENT
{
uint dwSize;
uint dwID;
int iComponentType;
bool fChecked;
bool fDirty;
bool fNoScroll;
COMPPOS cpPos;
char[] wszFriendlyName;
char[] wszSource;
}
[StructLayout(LayoutKind.Sequential)]
struct COMPPOS
{
uint dwSize;
int iLeft;
int iTop;
uint dwWidth;
uint dwHeight;
int izIndex;
bool fCanResize;
bool fCanResizeX;
bool fCanResizeY;
int iPreferredLeftPercent;
int iPreferredTopPercent;
}
[StructLayout(LayoutKind.Sequential)]
struct COMPONENTSOPT
{
uint dwSize;
bool fEnableComponents;
bool fActiveDesktop;
}
[StructLayout(LayoutKind.Sequential)]
struct WALLPAPEROPT
{
uint dwSize;
uint dwStyle;
}
// Declare IActiveDesktop interface
[Guid("F490EB00-1240-11D1-9888-006097DEACF9")]
interface IActiveDesktop
{
void ApplyChanges(uint dwFlags);
void GetWallpaper([MarshalAs(UnmanagedType.LPWStr)] string pwszWallpaper, uint cchWallpaper, uint dwReserved);
void SetWallpaper(string pwszWallpaper, uint dwReserved);
void GetWallpaperOptions(ref WALLPAPEROPT pwpo,uint dwReserved);
void SetWallpaperOptions(ref WALLPAPEROPT pwpo, uint dwReserved);
void GetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint cchPattern, uint dwReserved);
void SetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint dwReserved);
void GetDesktopItemOptions(ref COMPONENTSOPT pco, uint dwReserved);
void SetDesktopItemOptions(ref COMPONENTSOPT pcomp, uint dwReserved);
void AddDesktopItem(ref COMPONENT pcomp, uint dwReserved);
void AddDesktopItemWithUI(IntPtr hwnd, ref COMPONENT pcomp, uint dwReserved);
void ModifyDesktopItem(ref COMPONENT pcomp, uint dwFlags);
void RemoveDesktopItem(ref COMPONENT pcomp, uint dwReserved);
void GetDesktopItemCount(int lpiCount, uint dwReserved);
void GetDesktopItem(int nComponent, ref COMPONENT pcomp, uint dwReserved);
void GetDesktopItemByID(uint dwID, ref COMPONENT pcomp, uint dwReserved);
void GenerateDesktopItemHtml([MarshalAs(UnmanagedType.LPWStr)] string pwszFileName, ref COMPONENT pcomp, uint dwReserved);
void AddUrl(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszSource, ref COMPONENT pcomp, uint dwFlags);
void GetDesktopItemBySource([MarshalAs(UnmanagedType.LPWStr)] string pszSource, ref COMPONENT pcomp, uint dwReserved);
}
// Declare ActiveDesktop as a COM coclass
[ComImport, Guid("75048700-EF1F-11D0-9888-006097DEACF9")]
class ActiveDesktop
{
}
}
namespace Wallpaper_test
{
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
ShellTypeLib.ActiveDesktop MyDesktop = new ShellTypeLib.ActiveDesktop();
ShellTypeLib.IActiveDesktop IDesk = (ShellTypeLib.IActiveDesktop) MyDesktop;
IDesk.SetWallpaper("Test.bmp",0);
IDesk.ApplyChanges(1);
}
}
}
|
|
|
|
|
I have randomly taken one method GetDesktopItemCount that wasn't working with your code, and got it to work thanks to slight modifications :
- declare this method as :
uint GetDesktopItemCount(out int lpiCount);
- use it :
int nbdesktops = 0;
uint hresult = IDesk.GetDesktopItemCount(out nbdesktops);
In other words, - IActiveDesktop is not a dispatch interface, so you must consume the HRESULT value in return. - out values are marshalled with the out attribute.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
With respect, that doesn't appear to be working either! I declared the GetDesktopItemCount as you did and then called in in my main program but I noticed that if I set nbdesktops to say 10 then after the function it is still 10! Also the HRESULT returned is non-zero even though no exception is thrown (it returns 0x129ADC which I don't know how to look up). Also what happened to the unit dwReserved parameter?
I declared the GetWallpaper function as:
uint SetWallpaper(string pwszWallpaper, uint dwReserved);
and it now seems to not throw an exception and even returns 0, but doesn't seem to actually do anything . I suspect that nothing will happen until I call the ApplyChanges method but that one still isn't working
|
|
|
|
|
Any luck with a solution for this problem? I would like to use the IActiveDesktop interface from a C# application as well.
I tried importing it via the Visual Studio method but I don't see the interface listed.
.:. Keno .:.
|
|
|
|
|
|
Apologies for reposting the question. I posted it first in the .NET forum. I am desperate to get an answer prompting me to post here again.
--------------------------
I created a .NET web service that was to be consumed by a .NET web application.
Now I have a problem. I made a session variable in the Web Service and stored the instance of the Web Service in a session variable in the Web application.
I have two problems
1. The session variable in the Web service is lost in subsequent calls.
2. The WebService object in the Web app session is NULL in every submit from the browser.
Have anyone implemented something like this? Is this the correct way to implement a state-ful Web Service?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
The session management mode in the config file of ASP.NET is "inproc"
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Hi Thomas
I had exactly the same problem starting with web stuff a short while back and I was like WTF??*&^*&*%%&^(*& are my objects?
The answer is short and sweet. In ASP.NET objects are stateless, meaning the will be recreated with every pageview.
Now the fix, and I'm not really sure if this the correct way, but all u need to do is mark those two variables in question as static. They will now retain their state.
Hope this helps
|
|
|
|
|
leppie wrote:
Now the fix, and I'm not really sure if this the correct way, but all u need to do is mark those two variables in question as static.
I tried this once and could not get it to work.
I just wanted to test it out so I built a webservice that incrimented a variable by one each time it was hit.
The variable was always zero.
|
|
|
|