|
im very new to NET and i apologize if this is a fundamental question, but i need some help.
i have an ascx file (inherits a cs file) loaded into an aspx file. in this code example, i click on the ascx file's radiobuttonlist. the radiobuttonlist's onselectedindexchanged methods fires a method in the ascx cs file. the cs method takes the value from the ascx radiobuttonlist and sets a cs property to the radiobuttonlist's selectedvalue. also, it takes sets a literal in the ascx file to the property value. in the aspx file, during the page_load, i call the ascx file's property and set the value to a literal inside the aspx file (but not in the ascx file). the code kind of works, but it's one click late. when i change the ascx radio buttons, the ascx literal updates. however, intially, the aspx literal does not change. the aspx literal does not change until the second radio button click.
i would greatly appreicate any help with this one. thanks from a newbie
void Page_Load(object s, EventArgs e)
{
string strControl;
Control ctl;
strControl = "radio";
ctl = LoadControl(strControl + ".ascx");
//((radio)ctl).choiceValue = "";
pl_radio.Controls.Add(ctl);
litResult.Text = ((radio)ctl).choiceValue;
}
<title>Radio Default File
<asp:placeholder id="pl_radio" runat="server">
From ASCX choicevalue property set during oo button click or radio
select change :
<asp:literal id="litResult" runat="server">
++++++++++++++++++++++++++++++++++++++++
ASCX file -
<%@ Control Language="C#" AutoEventWireup="true" Inherits="radio" %>
void Page_Init(object s, EventArgs e)
{
//choiceValue = "red";
}
<asp:radiobuttonlist id="rad_Choice"
="" onselectedindexchanged="button_click" autopostback="true" runat="server">
<asp:listitem text="Choice 1" value="1" selected="true">
<asp:listitem text="Choice 2" value="2">
<asp:literal id="litChoice" runat="server">
<asp:button id="btn_radio" onclick="button_click" text="Submit"
runat="server">
+++++++++++++++++++++++++++++++++++++++
CS compiled - radio
public class radio:UserControl
{
public radio()
{
//
// TODO: Add constructor logic here
//
}
protected RadioButtonList rad_Choice;
protected Literal litChoice;
private string _choiceValue;
public string choiceValue
{
get
{
return rad_Choice.SelectedValue;
}
set
{
_choiceValue = value;
}
}
public void button_click(object s, EventArgs e)
{
choiceValue = rad_Choice.SelectedValue;
litChoice.Text = choiceValue;
}
}
-- modified at 16:05 Thursday 28th December, 2006
|
|
|
|
|
i found the answer in google. by adding the loadcontrol in the aspx page_init and then retreiving it in the page_load, i was able to get the ascx property value after each radiobutton click.
<%@ Page Language="C#" AutoEventWireup="true" %>
protected Control ctl;
string strControl;
void Page_Init(object s, EventArgs e)
{
strControl = "radio";
ctl = LoadControl(strControl + ".ascx");
//((radio)ctl).choiceValue = "";
pl_radio.Controls.Add(ctl);
}
void Page_Load(object s, EventArgs e)
{
litResult.Text = ((radio)ctl).choiceValue;
}
<title>Radio Default File
<asp:placeholder id="pl_radio" runat="server">
From ASCX choicevalue property set during button click or radio select change :
<asp:literal id="litResult" runat="server">
|
|
|
|
|
Hi.
Does anyone knows the way to parse (extract) data from Excel and CSV files?
Any help is appreciated.
Thank you,
Alex.
|
|
|
|
|
Eventhough I haven't come through that case, you can try OleDB or Excel.Application...
Regards,
Venkatesh Mookkan.
Software Engineer, India
|
|
|
|
|
I've heard about Excel.Application before. Do you know what library I should use?
Thank you,
|
|
|
|
|
Microsoft Office 11.0 Object Library
Regards,
Venkatesh Mookkan.
Software Engineer, India
|
|
|
|
|
Thanks. Do you have any examples. I can't find anything on the net.
|
|
|
|
|
|
hai friends,
my name is kishore kumar
actually i am getting one problem ,but i am unable to solve it
please help me
That is :
i will enter text(number), that should be changed into currency formate
that means suppose if i enter 99 in a textbox ,that shuld be changed to 99.00
and i have to show it as currency formate
i have three text boxes
in two text boxes, i will enter values , in third text box, the multiply of those two text boxes values shuld be displayed with currency formate
if i enter
first text box : 9
second text box : 11
out put :
third text box: 99.00 ,shuld be displayed
please help me,that should be done at client side
|
|
|
|
|
Nice homework assignment. First year, I see.
Is this JavaScript (as in title) or VB.NET (as in this forum).
|
|
|
|
|
Try this javascript function. This might be helpful.
function ChangeToCurrency (TargetString)
{
var Index;
if ((Index = TargetString.indexOf(".")) == -1)
TargetString += ".00"
else if (TargetString.substr(Index + 1).length == 0)
TargetString += "00"
else if (TargetString.substr(Index + 1).length == 1)
TargetString += "0"
return (TargetString);
}
Regards,
Venkatesh Mookkan.
Software Engineer, India
|
|
|
|
|
I have
<%@ Register TagPrefix="spm" Namespace="SolpartWebControls" Assembly="SolpartWebControls" %>
and
<spm:solpartmenu ...(options go here)... />
In my Bin folder is the SolpartWebControls.dll that this is referring to.
It all works great but I have a red line under solpartmenu and says "Element 'solpartmenu' is not a known element. This can occur if there is a compilation error in the Web site." and if I go to Design view I get "Error Rendering Control - PageTable An unhandled exception has occurred. Request is not available in this context". I normally wouldn't care but this is on a master page so all pages using is can't be viewed in design mode. I have very basic users that will be creating the other pages and if they can't use Design more then they can't create their pages.
Any help would be great, thanks.
|
|
|
|
|
I have a form that has 2 sections.
Each section has a textbox/ fileupload control and a button.
I want to add a RequiredFieldValidator for the textbox/ fileupload control and want to activate the validator only to the controls in that section, when the button in that section is clicked.
When Button1 is clicked, then RequiredFieldValidator for textbox1 in section1 should get activated and not the RequiredFieldValidator of the control textbox2.
How do I do it?
Thanks
Krutika
|
|
|
|
|
|
If this is in .NET 2.0, you can use the ValidationGroup property. If not, you will have to do you validation on the server side.
|
|
|
|
|
What the advantages of one over the other when I'm programing a page? I understand that when the page is run it will change all the asp:Table, asp:TableRow, and asp:TableCell into their HTML counterparts so why not just use the counter parts? I understand most of the other asp:components and why they are better but I can't find a reason for asp:Table.
So far I've noticed:
I can't use Height and Width on the CSS versions
I can't edit my cell contents in Design View
I can't set a background image on the fly (I currently am using a CSS file but it seems a waste since all it has in it is repeating backgrounds and each class is only used once)
Please tell me what I'm missing, what advantages I could gain, or if I should just start using the basic HTML table.
Thanks for any help.
|
|
|
|
|
The advantage is runat="server", which of course treats it as any other serve control to use, and abuse, as necessary with your code behide.
I don't understand the problems you are having with CSS, it is applied on the client side after the control has been rendered to appropriate HTML.
only two letters away from being an asset
|
|
|
|
|
The CSS issues aren't that big of deal but why can I edit my cell contents in design view?
|
|
|
|
|
Goal of the filewatcher window service: to look in a folder named ‘Watcher’ for a particular type of file. Whenever a new file arrives in the watcher folder, service should pick up the file, read contents, then delete the file from the folder and move it in another folder named ‘Processed’.
I am using filewatcher’s oncreated event for this. Whenever a file arrives, the oncreated event is fired. The problem I am facing is that the service is not able to read the file. The exception received is: The process cannot access the file
'\\WATCHER\abc_1959537.xml' because it is being used by another process. I tried to manually paste the files in ‘Watcher’ folder as well as in automated manner by a console application the result is same. Please help!
I m using this code:
private void filewatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
{
log.Info("file found :" + e.FullPath);
try
{
//Get the path of the recently arrived file
string fpath = e.FullPath;
//Get the xml string from file
FileStream objStream= new FileStream(filename, FileMode.Open,FileAccess.Read,FileShare.Read);
StreamReader sr = new StreamReader(objStream);
string tempstring = "";
string filestring = "";
while ((tempstring = sr.ReadLine()) != null)
{
filestring += tempstring;
}
sr.Close();
sr.Dispose();
//Move file in a new folder
FileInfo fi = new FileInfo(e.FullPath);
fi.Directory.CreateSubdirectory("updated");
File.Copy(e.FullPath, fi.DirectoryName + "\\Updated\\" + fi.Name, true);
fi.Delete();
log.Info("File Sucessfuly moved: " + fpath);
}
catch (Exception ex)
{
log.Info(ex.Message);
}
}
|
|
|
|
|
try wrapping the part that you open your stream reader in a using block,
Check out here
Also reading your code, I'm not quite sure where you the variable FileName get's it's values from?
the code is quite messy could do with some tidying up, tyhat way you could probably find the bug!
I tried something like this and it works fine for me?
StringBuilder sbXML = new StringBuilder();<br />
string fPath = e.FullPath.ToString();<br />
using(FileStream fStream = new FileStream(fPath,FileMode.Open,FileAccess.Read,FileShare.Read))<br />
using(StreamReader sr = new StreamReader(fStream))<br />
{<br />
while( sr.Peek() > -1)<br />
{<br />
sbXML.Append(sr.ReadLine());<br />
}<br />
}<br />
<br />
FileInfo fi = new FileInfo(e.FullPath);<br />
fi.Directory.CreateSubdirectory("updated");<br />
File.Copy(e.FullPath, fi.DirectoryName + "\\Updated\\" + fi.Name, true);<br />
fi.Delete();<br />
<br />
|
|
|
|
|
Thanks for your suggestions; I tried with your code also but facing same problem. Sometime the service successes in reading, moving and deleting file but sometime it gives error "process cannot access the file 'abc_4726137.xml' because it is being used by another process".
|
|
|
|
|
sorry I was busy today!
Instead of
FileInfo fi = new FileInfo(e.FullPath);<br />
fi.Directory.CreateSubdirectory("updated");<br />
File.Copy(e.FullPath, fi.DirectoryName + "\\Updated\\" + fi.Name, true);<br />
fi.Delete();<br />
Why don't you try File.Move ?
|
|
|
|
|
Hi! i want whenever i click on an item of a datagrid, then border color of that item become blue on client side. please help me.
|
|
|
|
|
Hey Nigam Samir,
I believe I can help you...
Please Add the following code into the DataGrid ItemDataBound Event.
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes("onclick") = "javascript:this.bgColor='blue';"
End If
Have a happy programming...
Regards,
Venkatesh Mookkan.
Software Engineer, India
|
|
|
|
|
Thanks Venkatesh.
This code change back ground color of particular item not border color of that item.
|
|
|
|