|
Hi folks!
Maybe anyone can help me with this. I'm from WPF world and am used to bind to objects in other classes.
I found many examples to bind to lists, but none how to bind to a property of another class.
So here's the deal:
Default.aspx.cs
private DefaultVM vm;
protected void Page_Load(object sender, EventArgs e)
{
this.vm = new DefaultVm();
}
DefaultVM.cs
public int TestValue { get;set;}
public void DefaultVM()
{
TestValue = 10;
}
Default.aspx
<asp:Label runat="server" Text="<%# vm.TestValue%>"/>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"TestValue")%>'/>
<asp:Label runat="server" Text='<%# DataBinder.Eval(vm,"TestValue")%>'/>
None of this works.
Tried a few other things as well, but without result.
What am I doing wrong?
|
|
|
|
|
Try this:
<asp:Label id="lblTest" runat="server" />
then, in Default.aspx.cs (perhaps in OnLoad or wherever you deem appropriate)
vm = new DefaultVM();
lblTest.Text = vm.TestValue.ToString();
Mod: Sorry, yes, just thought: that probably wasn't the answer you were looking for. Make private DefaultVM vm; to public DefaultVM vm; that should do it.Tychotics: take us back to the moon
"Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars."
H. G. Wells
modified on Friday, February 26, 2010 6:05 AM
|
|
|
|
|
Thank you! That did it:
'<%# DataBinder.Eval(DataItem.vm,"TestValue")%>'
and defining
public DefaultVM vm;
|
|
|
|
|
i have enter the textbox or dropdownlistbox value EX:(kannan)
but i want get first charter to disply other textbox. EX : kSir/Mam,
I'm Kannan.I Like very much for the coding for the project
THANKNG YOU
KANNAN
|
|
|
|
|
OnBlur call a javascript function.
In the function take the value in textbox
var my_car="Ferrari";
var the_char=my_car.charAt(0);
using the above u can get the first character and assign to the second text box.
But be careful, if any postback is happening after this as the value may disappear (as u r assigning in client side). For this you can use hidden value and store in it.
NainaNaina
|
|
|
|
|
ya its fine..and some one douats
i display first 3 charter and assign in other textbox..Sir/Mam,
I'm Kannan.I Like very much for the coding for the project
THANKNG YOU
KANNAN
|
|
|
|
|
Hi, this will be a bit tricky to explain but I'll try my best.
Original page:
I have a page with a button, which when clicked will generate a spreadsheet and prompt the user to download this spreadsheet.
Changes:
Now since we didn't want to the page to refresh,
and at the same time we didn't want to implement an UpdatePanel to this page,
we changed this button to a link which pops-up a new page.
New page:
The new page simply contains this button and a javascript link to close the window.
I did not change the source code of the generate-spreadsheet method.
Generate spreadsheet method:
public static void Export(Page webPage)
{
webPage.Response.Clear();
webPage.Response.Buffer = true;
webPage.Response.Charset = "";
webPage.EnableViewState = false;
string filename = "spreadsheet.xls";
webPage.Response.ContentType = "application/vnd.ms-excel";
webPage.Response.ContentEncoding = Encoding.Default;
webPage.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName + ";");
string filePath = string.Format("{0}temp\\{1}", webPage.Request.PhysicalApplicationPath, fileName);
populate(filePath);
webPage.Response.TransmitFile(filePath);
webPage.Response.Flush();
File.Delete(filePath);
webPage.Response.End();
}
Problem:
Now here's my problem, the code works perfectly on my local machine, but does not work when I deployed on the server.
On my local, it correctly gives me a download dialog with "spreadsheet.xls" displayed.
On the server, it gives me a download dialog, but the URL (http://www.oursite.com/WebForms/WFrmExport.aspx) of the pop-up page is displayed instead. So when I click "Save", it will just give me an error.
Additional notes:
1. The same export method is used in the original page and the new pop-up page
2. Both original pages and pop-up pages are webforms (*.aspx)
3. The original page works on the server... meaning it correctly prompts me to download "spreadsheet.xls". The problem only occurs on the pop-up page and only on the server.
4. If I remove the File.Delete(filePath); statement, I will see the generated spreadsheet.xls in the correct filepath server directory, which is the same directory used by the original page.
What could be the problem?Rafferty
modified on Friday, February 26, 2010 12:40 AM
|
|
|
|
|
I this it may be the issue of reading file form the server machine so you have to set account of the person who can access the local file system form server to do this :
go to IIS Manager > right click on DefaultAppPool
>> Go to poperties >> Go to Identity Tab >> set security account to local system
|
|
|
|
|
Hi, thanks for your reply. I don't think this is the problem because it can properly download the file if I revert back my changes in the server. The old code and the new changes both access from the same file location.
this is a big headacheRafferty
|
|
|
|
|
I finally found the solution!
I also had to clear the headers of the response, apparently, Response.Clear() only clears the content.
Maybe the header was somehow populated incorrectly by the new pop-up page.
So the fixed method is:
public static void Export(Page webPage)
{
webPage.Response.ClearHeaders();
webPage.Response.Clear();
webPage.Response.Buffer = true;
webPage.Response.Charset = "";
webPage.EnableViewState = false;
string filename = "spreadsheet.xls";
webPage.Response.ContentType = "application/vnd.ms-excel";
webPage.Response.ContentEncoding = Encoding.Default;
webPage.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName + ";");
string filePath = string.Format("{0}temp\\{1}", webPage.Request.PhysicalApplicationPath, fileName);
populate(filePath);
webPage.Response.TransmitFile(filePath);
webPage.Response.Flush();
File.Delete(filePath);
webPage.Response.End();
}
Thanks to all who wanted to help! Rafferty
|
|
|
|
|
I am trying to get jquery datepicker to work on a textbox I have on an asp usercontrol.
This is what I have been trying to achieve:
when a menuclick event is fired from a menu control on the parent page,
The usercontrol is loaded into the placeholder (which is itself placed in an ajax update panel on the parent page)on the parent page . Please how do I register the jquery datepicker on the usercontrol. I need detailed explanation cuz am kinda new to asp, with little experince with client scripts. I am working with c#, thanks.
|
|
|
|
|
Have you read the JQuery documentation[^]?
$("id of textbox").datepicker();
That's it. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hello,
I have defined an entity data model in my ASP.NET VB project that contains a PartList entity. I have created an entitydatasource that returns the Part Name, NSN and RecID (primary key). I have also created a dropdown list that contains values PartName and NSN and a textbox that will contain the search criteria.
How would I define my entitydatasource parameters to query it.[NSN] if dropdownlist.selectedvalue = NSN and query it.[PartName] if dropdownlist.selectedvalue=PartName and submit the textbox.text as the search string? Is gridview a good candidate to display the results? Should the search controls and gridview be placed on the same page or separate pages? Finally, the ultimate goal is for the user to click the checkbox next to the parts they want and those selected parts are passed on to a wizard control. Do I use stringbuilder to get the selected parts and send them to the wizard control?
Thanks,
Sid
|
|
|
|
|
Hi
I am building a library of asp.net user controls which I am deriving from a custom UserControlBase class which further derives from actual UserControl class. Hierarchy looks like this :
ASCX -> UserControlBase : UserControl
I have this requirement to put a border around all the ASCX's. So, I thought if I can modify UserControlBase it will apply to all ASCXs. I tried following code in Page_Load of UserCOntrolBase but its not working
this.Attributes.Add("style", "border-color:#FFFF66;border-width:4px;border-style:Dashed;");
What should I do to make it work? Please advise.
Thanks
AJFollow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
You should use CSS classes rather than hard code these values. When users ask to change it, and they will, it will be much easier.
Create a div in the control to act as the border and set its properties not the control itself. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Agree with Mark Nischalke, Css more easier
|
|
|
|
|
Hi,you can try like this: XXX.Style["border-color"] = "#FFFF66;border-width:4px;border-style:Dashed";
modified 27-May-14 4:53am.
|
|
|
|
|
Hello,
I am having trouble getting an RSS feed to work on a college project, I am using code based on a tutorial I got from here http://blogs.msdn.com/coding4fun/archive/2006/10/31/912335.aspx
When i try to run I am getting an error that looks a bit like this
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The base class includes the field 'rssFeed', but its type (RssList) is not compatible with the type of control (ASP.rsslist_ascx).
Source Error:
Line 7:
Line 8:
Line 9: <rss:feedControl ID="rssFeed" runat="server" />
Line 10:
Line 11:
Source File: /News.aspx Line: 9
Any help with this problem would be fantastic.
Cheers,
D
|
|
|
|
|
they have used UserControl. u just try without UserControl, the method is very simple. just have a look
1. call the RSS content with its URL. It will return XML
2. Convert XML to dataset
3. Since u got the dataset you know what to do
4. Show That in u r page/ if u want u can store that also for future.
5. If u want to format the resultant XML use XSLTmodified on Friday, February 26, 2010 1:42 AM
|
|
|
|
|
how do u edit the labels in a listview dynamically for the header template in vb.net
we have labels for header template and depending upon the value of one of the columns in the datasource the header label needs to change.
|
|
|
|
|
hi,
how to publish website throught IIS
|
|
|
|
|
Have you at least tried to read the documentation or have go? What problems did you encounter? What did you do to try to resolve them before posting here?Tychotics: take us back to the moon
"Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars."
H. G. Wells
|
|
|
|
|
|
|
thanks a lot its helpful to me thanks
|
|
|
|