|
Ok. Thanks I understood.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Try here:
RegexBuilder[^]
RegexBuilder is a simple tool which helps developers to create and test regular expressions.
|
|
|
|
|
Hi I want to return a list of records on button click of user control.
I already have the collection ready , but I dont know how to return the collection to the calling page.
How do I bind results of user control with gridview on parent page on user control button click ?
My user control code
public partial class assets_WebControls_ftExclusions : System.Web.UI.UserControl
{
private int _id;
private ftExclusionsList myftExclusions;
public int ID
{
get{return _id;}
set{_id=value;}
}
public ftExclusionsList selectedExclusions
{
get { return myftExclusions; }
set { myftExclusions = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
cblExclusions.DataBind();
ftExclusionsList myExcluList = ftExclusionsManager.ftExclusionsById(ID);
if (myExcluList != null)
{
if (myExcluList.Count > 0 && myExcluList != null)
{
foreach (ftExclusions ex in myExcluList)
{
cblExclusions.Items.FindByValue(ex.excluId.ToString()).Selected = true;
}
}
}
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
ftExclusionsList myFTExclusionList = new ftExclusionsList();
foreach (ListItem li in cblExclusions.Items)
{
if (li.Selected == true)
{
ftExclusions myftExclusion = new ftExclusions();
myftExclusion.excluId = Convert.ToInt32(li.Value);
myftExclusion.excludesc = li.Text.ToString();
myFTExclusionList.Add(myftExclusion);
}
}
selectedExclusions = myFTExclusionList;
}
}
|
|
|
|
|
AFAIK, You can not return something from click event.
To achieve your goal, you can have a public property which holds the list of records. Assign this property with the list in click event. And after this, you can access this property from the page to get the list of records.
|
|
|
|
|
Thanks for the reply.
How about I define a private variable gridview inside my user control.Pass the value of parent page gridview to this private variable of user control.
And on button click of user control, bind the private gridview with collection ? I cant get it to work though but just a question.
|
|
|
|
|
Hi,
if i were you, i would not start passing controls from one page or usercontrol to another.
The method explained in the above post is the way to go. Always keep in mind that your controls/classes should have a (clean seperated) job.
Maybe you wanna reuse this control somewhere else where the calling page doesnt have/need a gridview? keep your "interfaces" as simple as
possible.
So, in your UserControls' Button click event, raise an event or something, which is subscribed in Page load of your Page class.
This ways, your page can access the mentioned public property of your usercontrol once the event occurs. Or you could even pass your "result"
though this event/delegate and access it without the necessity of a public/internal property.
|
|
|
|
|
Hello Michael. Thanks for the reply. Actually I have to show hide the user control on button clicks on page. That is why there is a update button on the user control, which when clicked would update the gridview on parent page and hide the control.
If I were to store the values in the checkbox list click event I still have to pass them on to the parent gridview. Can you elaborate a little with some example or hint what you want me to do ?
|
|
|
|
|
Hi,
i was talking about the button click event in your usercontrol. You have to somehow
let the page know that the user clicked the button within your usercontrol. You could
do this by using a delegate similar to this. I made a comment there with an example.
You have to replace the text-parameter by your custom item collection. This would work.
(Or you just notify the page and the page accesses the items though a public property of
your control).
Does this help or am i confusing?
|
|
|
|
|
Hi thanks for the reply, Ermm its not confusing but maybe too hitech for me.
I took the update button out of user control and made its method as a private method inside user control ,
I am trying to expose the updated collection though a public property of user control now. Only thing bothering me is that I cant call the private method inside user control and populate the collection on call of the public method of user control.
In presentation page I am calling the the public attribute but it is returning null right now because the private method is not called.
public partial class assets_WebControls_ftExclusions : System.Web.UI.UserControl
{
private int _id;
private ftExclusionsList _myftExclusions;
public int ID
{
get{return _id;}
set{_id=value;}
}
public ftExclusionsList selectedExclusions
{
get { return _myftExclusions; }
set { _myftExclusions = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
cblExclusions.DataBind();
ftExclusionsList myExcluList = ftExclusionsManager.ftExclusionsById(ID);
if (myExcluList != null)
{
if (myExcluList.Count > 0 && myExcluList != null)
{
foreach (ftExclusions ex in myExcluList)
{
cblExclusions.Items.FindByValue(ex.excluId.ToString()).Selected = true;
}
}
}
}
}
private void SelectedExclusions()
{
ftExclusionsList myFTExclusionList = new ftExclusionsList();
foreach (ListItem li in cblExclusions.Items)
{
if (li.Selected == true)
{
ftExclusions myftExclusion = new ftExclusions();
myftExclusion.excluId = Convert.ToInt32(li.Value);
myftExclusion.excludesc = li.Text.ToString();
myFTExclusionList.Add(myftExclusion);
}
}
selectedExclusions = myFTExclusionList;
}
}
|
|
|
|
|
If it is just about the collection you want to expose now, you
can either do this:
public ftExclusions GetSelectedExclusions()
{
ftExclusionsList myFTExclusionList = new ftExclusionsList();
foreach (ListItem li in cblExclusions.Items)
{
if (li.Selected == true)
{
ftExclusions myftExclusion = new ftExclusions();
myftExclusion.excluId = Convert.ToInt32(li.Value);
myftExclusion.excludesc = li.Text.ToString();
myFTExclusionList.Add(myftExclusion);
}
}
return myFTExclusionList;
}
or this (property):
public ftExclusionsList SelectedExclusions
{
get { return GetSelectedExclusions(); }
}
private ftExclusions GetSelectedExclusions()
{
ftExclusionsList myFTExclusionList = new ftExclusionsList();
foreach (ListItem li in cblExclusions.Items)
{
if (li.Selected == true)
{
ftExclusions myftExclusion = new ftExclusions();
myftExclusion.excluId = Convert.ToInt32(li.Value);
myftExclusion.excludesc = li.Text.ToString();
myFTExclusionList.Add(myftExclusion);
}
}
return myFTExclusionList;
}
Then use the property OR method in the desired event of your page. This is all assuming that the rest of the code works.
A hint: Check for null before checking the count of a collection. Otherwise, you could get an exception. It is also usefull to check like
if (null==something)
if (something == null)
This way, you can prevent typing mistakes like If (something = null)...
GL
GL
|
|
|
|
|
i would create an interface that contains the method to update the page gridview.
public interface IMyInterface
{
public void UpdateGridview(ftExclusionsList theList);
}
implement the interface on the page.
protected void btnUpdate_Click(object sender, EventArgs e)
{
ftExclusionsList myFTExclusionList = new ftExclusionsList();
foreach (ListItem li in cblExclusions.Items)
{
if (li.Selected == true)
{
ftExclusions myftExclusion = new ftExclusions();
myftExclusion.excluId = Convert.ToInt32(li.Value);
myftExclusion.excludesc = li.Text.ToString();
myFTExclusionList.Add(myftExclusion);
}
}
selectedExclusions = myFTExclusionList;
((IMyInterface)this.Page).UpdateGridview(selectedExclusions);
}
this is the way i do it and i works like a charm
Andreas Johansson
IT Professional at Office IT Partner i Norrbotten Sweden
What we don't know. We learn. What you don't know. We teach
|
|
|
|
|
I have created a Windows Service. In the OnStart I added basic logging. The following is written to the log - "started on " + DateTime.Now.
I updated the code to pull from App.config and I commented out the original hard-coded code.
I uninstalled, rebuilt and reinstalled. Weird thing is - the old "started on" text is still getting written to the log even though I've commented out in the code. I changed the text in App.config to something completely different.
So - How is this possible and what might I be missing?
|
|
|
|
|
Clear cache... delete bin.. clean solution... restart system!
Last one... Reset IIS!
|
|
|
|
|
Maybe there's something wrong with the way I'm installing/uninstalling/reinstalling?
I have a solution with a Windows Service and an associated Setup project.
This is at least partially right because it lets me install/uninstall/reinstall the service.
One interesting thing though - I have to restart my computer before I can reinstall. Is this a bug with Microsoft or is there a workaround?
It looks like only the code that I wrote when I created the initial setup project is getting installed.
My assumption was that the setup project maintained a reference to the windows service that I created in the solution. So usually in .NET solutions when you add a reference to an external project any changes to that external project are automatically made available to the referring project in the solution.
Do service/setup solutions work the same way? I was assuming that they did. This is the only reason I can think of why my code updates don't seem to be getting applied.
|
|
|
|
|
clear the textbox where the data is displayed at page loading. hope this helps.
|
|
|
|
|
does the dataview will remove the null value columns, i faced when i am assigning datatable to view?
|
|
|
|
|
Your question is not complete. What are your trying to do and whats happening?
Dataview wouldn't do anything by its own. Read: DataView Class[^]
|
|
|
|
|
I've written a Windows Service and I'm trying to get it to auto-start after install.
The "Startup Type" is "Automatic" but this only starts the service after a computer restart.
I've found a few posts that recommend the following code:
public ProjectInstaller()
{
InitializeComponent();
this.AfterInstall += new InstallEventHandler(ProjectInstaller_AfterInstall);
}
void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
{
ServiceController sc = new ServiceController("TestWindowsService");
sc.Start();
}
However, this code doesn't appear to be starting the service for me after install. Any suggestions on what might be missing?
|
|
|
|
|
I think you need to initiate another event:
this.Committed += new InstallEventHandler(ServiceInstaller_Committed);
void ServiceInstaller_Committed(object sender, InstallEventArgs e)
{
var controller = new ServiceController(strServiceName);
controller.Start();
}
Have a look here: Auto Start Windows Service After Installation[^]
|
|
|
|
|
I have little problem. I am trying to get id of cell and put value in this cell with this js function:
<br />
function fill_table(grid){<br />
var str=grid.toString();<br />
str=str.replace(/\n/g," ");<br />
var ar_grid=str.split(" ");<br />
var c=0;<br />
for(var i = 0; i < 81; i++)<br />
{ <br />
c=i+1;<br />
ar_grid[i]=ar_grid[i].replace(/0/gi,"");<br />
document.getElementById('cell_'+c).value=ar_grid[i]; <br />
}<br />
}<br />
This works fine with html table but how to do this with asp table.
I addded ID to each cell like this:
<br />
TableCell c=new TableCell();<br />
c.Attributes["ID"]= "cell_" + st;
|
|
|
|
|
Aljaz111 wrote: c.Attributes["ID"]= "cell_" + st;
Why doing this? Why not... c.ID = "cell_" + st;
|
|
|
|
|
for set ID by asp table, you use as below
TableCell c=new TableCell();
c.ID = "cell_" + st;
Thanks,
Amit
With Regards,
Amit Patel
91-9328488961
India
|
|
|
|
|
stil with adding ID to cell like this doesn't work. Does asp:table need to postback to get filled with values from javascript?
|
|
|
|
|
Hello, This is Vikash Gohil.
I have developed a web Application and Now I want to add functionality of evaluation period in my web app, so that I can give my application as Demo to customers.
Can anyone please suggest me some functionality for this or some guidelines how to achieve this.
Any information would be greatly appreciated.
Thanks in Advance, Awaiting a reply soon.
|
|
|
|
|
See, There are various ways to do this.One simple way,have a file and store the starting time of your application and store that file and always check the time at starting of your application and if is older tham the spcified period then show a message. Store the data in encrypted format.
Another way, make a entry in registry at very first time check the time each time user starts the application, accordingly show the message
|
|
|
|