Hi,
Can someone please let me know by some code how I can call a function located in the Form class from another class?
Some code will be of great help!
thanks
Hi awesome!
We know that MarshalByRef allow us to create an object in a different AppDomain and use a Proxy object to access it. And the behavior of that object is in a different context of the AppDomain where it actually lives in. Well this sounds faily reseaonable in the regard of isolation and safety.
But why is there still MarshalByValue? MarshalByValue just leads to an newly deserialized object which is an exact copy of the object in a different AppDomain. If we need that object, why not just create it in the current AppDomain? Why bother to first create it in a different AppDomain and then get it back by MarshaoByValue?
Many thanks.
Hi,
Is it possible to generate a proxy class from WSDL and use the proxy class for other communication protocol?
For example, my application generate the new proxy class and then use this class as a standard for sending request and receiving response messages on TCP, JMS, etc.
Thanks
Hi all
I know that the EURO currency symbol (€) is encoded as € in HTML, but the System.Web.HttpUtility.HtmlEncode("€") doesnt encode it at all. Does anyone know why that is?
Thanks
In my web.config file i have the following code:
<system.web>
<assemblies>
<authentication mode="Forms">
<forms loginUrl="/Account/Login" slidingExpiration="true" timeout="1" />
</authentication>
<sessionState timeout="1"></sessionState>
</assemblies>
</system.web>
And I have main page Project and in that there will sub pages. I have given the [Authorize] attribute for each view index method.
After the session complete when we select any view then the page inside the project main page will be redirecting. But I want the whole page to be redirected.
Any Help is appreciated.
I'm trying to display the picture associated with a user in my database (the picture field's data type is image) on a page - unfortunately the code below fails to do that.
HTML
<img src="/User/Picture/1" />
Controller Action
public byte[] Picture(int id){
UserRepository r = new UserRepository();
return r.Single(id).logo.ToArray();
}
I have a very big table with a lot of rows, every row has stats for every user for certain days. And obviously I don't have any stats for future. So to update the stats I use
UPDATE Stats SET Visits=@val WHERE ... a lot of conditions ... AND Date=@Today
But what if the row doesn't exist? I'd have to use
INSERT INTO Stats (...) VALUES (Visits=@val, ..., Date=@Today)
How can I check if the row exists or not? Is there any way different from doing the COUNT(*)?
If I fill the table with empty cells, it'd take hundreds of thousands of rows taking megabytes and storing no data.
I have a C# function that does some processing and needs to return figures about what it has processed, success, failure, etc.
Can anyone tell me if there are any standard framework classes that will handle this (for example, number of records processed, number successful, failed, etc) ?
Alternatively, can anyone say how they usually handle this? Is the best way to create a class, or to use out parameters?
Hi guys,
I'm creating a shopping cart application and I'm having some issues with implementing a session state for my arraylist.
in my page load i declared
if (Session["Cart"] == null)
{
Session["Cart"] = new ArrayList();
}
else
{
ArrayList cart = (ArrayList)Session["Cart"];
}
to create the session if it doesn't exist yet.
then i have an event handler for a button to add items to the arraylist
protected void onClick_AddBooking(object sender, EventArgs e)
{
int ClassID = Convert.ToInt32(Request.QueryString.Get("Class_Id"));
ArrayList cart1 = new ArrayList();
cart1 = Session["Cart"];
cart1.Add(ClassID);
i'm guessing i just don't know how to handle session states yet, thus the confusion.
I'm essentially storing the class_ID then when the student confirms i'll store that to the DB and associate that ID with the Class Details.
Thanks in advance guys!
I'm attempting to validate the input of a text box which corresponds to a property of type double in my model. If the user inputs "foo" I want to know about it so I can display an error. However, the ValueProvider is dropping the value silently (no errors are added to the ModelState).
In a normal submission, I fill in "2" for the text box corresponding to myDouble and submit the form.
Inspecting controllerContext.HttpContext.Request.Form shows that myDouble=2, among other correct inputs. bindingContext.ValueProvider.GetValue("myDouble") == 2, as expected. The bindingContext.ModelState.Count == 6 and bindingContext.ModelState["myDouble"].Errors.Count == 0. Everything is good and the model binds as expected.
Then I fill in "foo" for the text box corresponding to myDouble and submitted the form.
Inspecting controllerContext.HttpContext.Request.Form shows that myDouble=foo, which is what I expected. However, bindingContext.ValueProvider.GetValue("myDouble") == null and bindingContext.ModelState.Count == 5 (The exact number isn't important, but it's one less than before). Looking at the ValueProvider, is as if myDouble was never submitted and the model binding occurs as if it wasn't. This makes it difficult to differentiate between a bad input and no input.
Is this the expected behavior of ValueProvider? Is there a way to get ValueProvider to report when conversion fails without implementing a custom ValueProvider? Thanks!
I have two pages page1.aspx and page2.aspx, both have code behind with partial classes.
How do i access public property message on page1.aspx from page2.aspx ?
public string message { get; set; }
I'm passing query string parameter to .aspx page with 'Ñ' character in value.
But Request.QueryString returns some other box '[]' character in return.
I think this request encoding issue. and I do not want to use that HttpUtility.UrlDecode and HttpUtility.UrlEncode methods.
Does anyone know how to solve this?
Hi, I have the code (snippet):
The Model is the IEnumerable object of the Person's class:
<% foreach (var item in Model)
{ %>
<tr>
<td><%= Html.DisplayFor(x=>item.Name) %></td>
</tr>
<% } %>
it renders only labels like that:
<td>Tommy</td>
According to the link it should be rendering a HTML markup something like:
but there is no the ID and the NAME property. Why ?
i was wondoring which thing is better from below two...
first one-
retrive data by creating webservice
second one-
create database connection from code behind call storeprocedure and retive data
can anyone one explain how it differs.
I have my repeater item template:
<ItemTemplate>
<tr><td><%#Container.DataItem("Category")%></td></tr>
</ItemTemplate>
Hooked up to:
s = "SQL that works ok on server"
x = New SqlCommand(s, c)
x.Parameters.Add("@contentid", SqlDbType.Int)
x.Parameters("@contentid").Value = contentid
c.Open()
r = x.ExecuteReader
If r.HasRows Then
Linksrepeater.DataSource = r
Linksrepeater.DataBind()
End If
c.Close()
r.Close()
When I run the code I get: Invalid Cast Exception was not handled by user code (Conversion from string "category" to type 'Integer' is not valid.)
I'm not sure how / why it is trying to convert "Category" to integer as in the db it is a string.
Can you please tell me how to avoid this error? thanks.
I've been using my own Error reporting module which was combination of simple c# and jQueryUI Dialog. Problem is that once error or success occurs i do write it's value to session. It does work pretty good on pages with Responce.Redirect on error but not on pages where i catch an error and then return to same form.
My question is why does session which added pre-postback fails to load in pages where i have return statement on some condition.
And if there another way to save errors and success message except in session ? Maybe global variables or something like that ...
On my master page I have:
<link rel="stylesheet" href="css/default.css" />
I also have a page "blog.aspx" in the root directory.
I have the rule:
<rewrite url="~/blog/blog.aspx" to="~/blog.aspx" />
My questions are:
Am I meant to make all my links in my site point to blog/blog.aspx now instead of just blog.aspx where it is physically located
How is best to cope with the paths of the stylesheets etc now being messed up because they are one dir up?
I bind custom DataTable to DataGrid through ObjectDataSource, where i use SelectMethod and UpdateMethod. SelectMethod working great, but when I try to update row it's breaking by MissingMethodException. What should i do to fix this problem?
Sorry for my bad english ;)
Hi I have the following codes
$('#<%= btnOpen.ClientID %>').click(function() {
$('#content').modal();
});
<asp:Button ID="btnOpen" runat="server" Text="Open" />
When I click on the button, the modal window will appear for about 0.5 second and disappear right away.Can anyone help me please? Thanks a lot!
I have custom control with asp textbox inside.
And i need to Validate by RequiredFieldValidator my custom control on CLIENT side.
I added attribute to custom control class:
[ValidationProperty("Text")]
public class WatermarkTextBox : System.Web.UI.UserControl
{
}
It looks like working but it always make submit to server. How can i check it only on client side?
I've been given a task to make a dynamic drop down which takes it's data[image and value id] from table. I am wondering if any of you came across this scenario or if any one can help me out in this I need help in concept and coding. Definitely any help is appreciated.
I see the example in jquery here is the link:
http://www.marghoobsuleman.com/jquery-image-dropdown
something like this but data is coming from table.
the thing is that I have a form with a textbox and a button and a hidden field, now what i want to do is to write something in the textbox ,pass it to the hidden field and then access that thing written in the hidden field in the controller . how can i do that?
Hi, I have a strange problem happening today. I am running the latest version of the MVC V2 framework and have been having no trouble at all - I came in this morning and for some reason values aren't being passed in to actions.
To clarify lets say I have something like this:
<% using (Html.BeginForm("Register", "Registration", FormMethod.Post)) { %>
....
<input type="submit" name="register" id="register" value="Register" />
<% } %>
And in my controller I have the following:
[HttpPost]
public ActionResult Register(RegistrationModel model, string register)
{
// At this point the register string is null
}
This has been working fine for a while now and I have not changed anything that I can think of that would cause this to happen.
Does that make sense and as anyone any idea what is going on or what I have messed up?
Thanks.
We are operating a corporate web application on a load-balanced cluster that consists of two identical IIS servers talking to a single MSSQL database.
To deploy updates I am using this primitive process:
1) Make a copy of the entire site folder (wwwroot\inetpub\whatever) on each IIS box
2) Download the updated, compiled files onto each IIS box from our development area
3) Shut down IIS both web servers
4) Copy the new and updated files into the wwwroot folder (overwriting any same files)
5) Then restart IIS on both machines
When there are database changes involved there are a few other steps.
The whole process is fairly quick but it is ugly and fraught with danger, so it has to be done with full concentration. I would like to just push one button to make it all happen. And I want a one-click rollback in case there is a problem (that's the reason I make the copy in step #1).
I am looking for tools to manage and improve this process. If it also helped us maintain a changelog, that would be nice.
Thanks.
I have a windows service which is trying to access an xml file from the Application directory.
Windows Service Installed directory : C:\Services\MyService\MyService.exe
Path of the xml file : C:\Services\MyService\MyService.xml
I am trying to access the file using the following code.
using (FileStream stream = new FileStream("MyService.xml", FileMode.Open, FileAccess.Read))
{
//Read file
}
I get the following error.
"Can not find file : C:\WINDOWS\system\MyService.xml"
My service is running with local system account and I don't want to use absolute path.