|
In your book, check out:
Day 13—Reading and Writing Files on the Web Server.
Using Files with ASP.NET. Including External Files. Accessing Files. Isolated Storage.
|
|
|
|
|
What else can I do to learn .net?
|
|
|
|
|
In the application that I'm building, I ask a question in the form and I have a drop down list with yes or no as the values. If the user selects no, I need a validation to occur that says, Sorry but we can't process your application at this time. Can someone help out?
|
|
|
|
|
In your button's OnClick event, just add code to check it.
If (ddlWhatever.SelectedValue = "No") <- or whatever it's VALUE is
Response.ReDirect( your url);
|
|
|
|
|
Say you have Two DropDownLists
DDL1
DDL2
DDL1=Start Year 2005
DDL2=End Year 1999 End Year is Less Than Start Year!
How do you validate if End Year is Less Than Start Year. I already tried the compare validator with the Less Than Operator, it didn't work. Any Suggestions?
|
|
|
|
|
Hi!
I have a parent user control and it has a child user control. In the childs Page_Init function I want to use a variable from the parent.
parent:
Code:
...
protected int a = 21;
...
child:
Code:
...
private void Page_Init( ... )
{
...
//here I want to get a hold of variable a
}
...
How can I do this?
gdfgdfg
|
|
|
|
|
Iterate through the Controls to find it, if it's HasControls property is true.
|
|
|
|
|
Create a property on the child control and set it in the parent at page load or init
ChildUserControl
property ?? MyValue { MyPrivate = value; }
ParentUseControl_OnLoad()
{
Child.MyValue = 21;
}
only two letters away from being an asset
|
|
|
|
|
Hello, I would like to change the color and font in a aspx page when a button or a link is clicked (so it has to be an event triggered by a user). I can’t just use CSS since that’s static and it will be changed forever and not dynamically on the button click event. And I don’t want to use JavaScript because of the browser restrictions that we are running into. So I have to do it on the server side (that is in the button1_click event). Please help me out with that.
Thanks
Tina
|
|
|
|
|
Are we talking about a large amount of text or just a couple of things?
There are several options that I can think of.
You can enclose your text in a normal or tag, only add a 'runat' and 'id' directive. Doing this gives you access to a "Style" property programmatically. For example:
<br />
<p runat='server' id='myPara'> Here is some sample text. </p><br />
<br />
myPara.Style = "color:red; font-family:Arial";<br />
<br />
However, a way that you can still use CSS is to encompass your text in an <asp:label> control. This gives you access to a property called "CssClass". So then in your button click event you can do something like:
<br />
lblMyText.CssClass = "MyCssStyle";<br />
|
|
|
|
|
Hello there, thanks for the quick response. However I'm just changing the color of a particular control like you mentioned. I'm actually going to be changing the entire page's color and font. And that's why I looked at htmlForm element.
HtmlForm frm = new HtmlForm(); Now this has a bunch of properties and methods but bgColor or anyother way of changing the color is not provided. The same thing applies to your other suggestion regarding the styles sheet, since its the entire page I don't know if we associate the class attribute to the whole form. Any ideas???
Thanks
Tina
|
|
|
|
|
Well just like the <p> or <span> I mentioned, HtmlForm has a "Style" property where you can make css-like declarations... i.e.,
frm.Style = "background-color:yellow; font-weight:bold";
or whatever.
|
|
|
|
|
Sounds like you guys all like CSS a lot. Actually to be honest I don’t want to use CSS for this particular task. My requirement is really to sort of provide and alternative color and font and hard code that in their so that when the link is clicked, it’ll trigger the event and the page (entire page will change color and font size).
HtmlForm frm = new HtmlForm();<br />
frm.bgColor= "yello";<br />
frm.FontSize= "12";<br />
tHANKS
TINA
|
|
|
|
|
It's not that I really like CSS -- though a lot of web developers do. (I consider myself a programmer who gets forced to do some HTML work by default!) It's that programmatically speaking Microsoft simply has not given us any other option when dealing with HTML controls from the server side. Server controls like asp:Label give us some more options, but obviously that won't work in the way you're trying to use it. Bottom line that for what you're trying to do, it's going to be the .Style property on HTML controls or bust.
|
|
|
|
|
use the .body class in CSS, it applies to the entire page, or body of the document.
only two letters away from being an asset
|
|
|
|
|
What If I don’t want to use CSS class, I’d just like to hard code some of these values on the server side. How do I do that.
Thanks
Tina
|
|
|
|
|
Tina P wrote: What If I don’t want to use CSS class
If you don't want maintainable, reusable code that makes proper use of the tools and technologies available to you, then that's up to you.
What it seems like you are doing is creating a set of different colors and fonts, and probably more, for your site and switching them based on some variable, probably a user action such as a button or listbox selection. In that case you are themeing your site and should use CSS or ASP.NET Themes.
only two letters away from being an asset
|
|
|
|
|
Mark, I can totally see what you are saying, however I have got to stick with what I’ve been told by my dev lead. Being a entry level person, I gotta take orders. And so if you could please tell me how do I do it on the server side without having to create a new CSS for this functionality. All I really want to do is to be able to change the color and size for the page on that button or link click event. Thanks Tina
|
|
|
|
|
Tina P wrote: I have got to stick with what I’ve been told by my dev lead.
Then send him our way, we'll get him straightened out for you
only two letters away from being an asset
|
|
|
|
|
Hi
I have to populate some datas from sql server database and display it directly in a CSV Format or CSV file. When i run the project it should provide me an option to whether open or save or cancel the file. when i click open it should be opened and be viewed in a excel sheet in CSV format and when i click save it should ask the destination folder and should be saved there in CSV format and when i click cancel it should be cancelled and the application should be closed. pls note that all these actions should happen in the same browser and should not be redirected to anyother page. Can anybody give me the detailed description and code in Asp.Net using C# .It's very Urgent.
Regards
Vijay.
|
|
|
|
|
hi all.
I want to write and create a scrapbook ( messageboard ) in C# ( asp.net) and my database is sqlserver 2000
I have problem in writing it. Can anyone help me and give me the code in C# ...?
I have created the table in database and the program is connected to database . I know I need to insert text(messsage) into database but how can I SHOW the posted message in the page...??
I want to show all the posts and the last post in the page...like here ...
please help me.
thanks alot.
|
|
|
|
|
Hi,
Please be more specific.. so that we can think of a possible solution.
SHIVAJI - The Boss
|
|
|
|
|
hi.
I need the C#.net code for scrapbook.
My database is sqlserver2000 and using visualstudio.net 2003
my scrapbook should be like this :
it has a textbox for writing the topic
a textbox for writing name
a textbox for writing the message.
a user writes a message in the scrapbook(textbox) of his friend and click on the button to send.after that,the user can see his message and also other messages in the scrapbook...
I know how to insert the data in table(database) but I dont know how to show the last and also the previous messages in the page...
thanks alot.
|
|
|
|
|
Don't crosspost this everywhere.
|
|
|
|
|
Not only are you impatient, asking this multiple times in the same forum, you also feel it's urgent enough to spam other forums.
only two letters away from being an asset
|
|
|
|