ASP.net C# Silverlight server component and ajax modal inside firefox - c#

I have a modal popup inside of an update panel with a silverlight control.
The video displays fine in IE 7/8 but in firefox all I get is a white screen
I am using the following video skin from link text
<div style="height:360px;">
<asp:Silverlight
ID="myVideoPlayer"
runat="server"
Source="~/Videos/VideoPlayer.xap"
Width="640px"
Height="360px"
InitParameters="m=Efficiency.wmv"
Windowless="true" />
</div>
I know it works when I use the normal <object> method but that will not work as I need to set the Initparams from the code behind depending on what video category they choose.
I have consulted the google gods and they have been not so helpful. Hope you guys can help me with this problem. Thank you!

I use Object tag, and init params injected to aspx like this :
<%= initparams %>
initparams is protected variable of my Page class:
public partial class _Default : System.Web.UI.Page
{
protected string initparams;
protected void Page_Load(object sender, EventArgs e)
{
initparams = "m=video.asx";
}
you can also change that variable in any event, it will be injected to rendered HTML.

Related

aspx pages not working after adding application in IIS

i have webapplication. In my master page i have few link buttons which are as below
<asp:LinkButton ID="link1" runat="server" OnClick="linkAge_Click">Age</asp:LinkButton>
<asp:LinkButton ID="link2" runat="server" OnClick="linkName_Click">Name</asp:LinkButton>
In my Visual studio i have seperate folder called Age and Name and under those there are default.aspx.
on click event of link button i have this code
protected void linkAge_Click(object sender, EventArgs e)
{
Response.Redirect("/Age/");
}
protected void linkName_Click(object sender, EventArgs e)
{
Response.Redirect("/Name/");
}
In IIS i added Application called "Test" and then added all code inside it
When i browse i get to master page as http://localhost:80/Test
When i click on link "Age" the url Changes to http://localhost:80/Age
I expected it to be http://localhost:80/Test/Age
What is wrong that i am doing? Can i achieve this without using any code changes.
Try to use http://localhost/Test/ (with slash in the end) link in to Your browser.
You need to add a tilde (~) to get URLs relative to application root:
Response.Redirect("~/Age/");
BTW: Why do you need to have the redirect behind a post-back? You could use <asp:HyperLink> instead
Like we do this in mvc to get path from root - Url.Content("~\Action\")
In web form -
protected void linkAge_Click(object sender, EventArgs e)
{
Response.Redirect(Server.MapPath("~/Age/"));
}
You got to think like this i think.
Since you're using only the /Age/ path, with nothing to indicate that you're using a relative path. For code managed by IIS, you'd use ~/Age/Whatever to indicate that you intend to go to Age relative to Test.

Page_Load firing when following link to another page asp.net

I'm fairly new to ASP.NET, I've been reading a few questions related to this but I'm still unable to figure out what's wrong with my code, I have a default.aspx page with a menu on top created using a list (ul and li items) and putting the <a href=""> tag to create the links to other pages but after following a link to another page, the Page_Load event fires before leaving the page, I understand this would be the expected behavior with Response.Redirect, but I don't know how to avoid this using tags (if possible), this is the markup I'm using for the Default.aspx page:
<ul id="lista">
<li><strong>Inicio</strong></li>
<li><strong>Item</strong></li>
<li><strong>IK</strong></li>
<li><strong>Acerca de</strong></li>
</ul>
And this is the code behind I have for Page_Load:
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
ExcelUtility excel = new ExcelUtility();
dtDefault = excel.LeerExcel();
gridResults.DataSource = dtDefault;
gridResults.DataBind();
gridResults.VirtualItemCount = dtDefault.Rows.Count;
}
}
Basically, what I want to do is to follow the link to some other page without loading the default page before leaving, hope I make myself clear!
Edit: The root cause of this was having the default <form runat="server"> tag at the beginning of the body section, this was causing the Page_Load event firing again in the same page once the links were being clicked, placing the hyperlinks outside of the form tag did the trick.
Your HTML code should be inside some HTML tag or custom ASP control which contains the attribute runat="server". This is supposed to fire a PostBack request to the server.

open HTML page from c#/asp.net

Is it possible from c#/asp.net to call/show a separeted html-page in the same window.
I don't want to store the entire html code into a
, for exemple...
(that works).
Possible with javascript? or do I have to modify the code-behind?
The purpose is to load this html page everytime the default.aspx is invoked, as a webform(pop-up)
You can Use iframe to open your .html page as:
.aspx Page:
<iframe id="ifrm" runat="server"></iframe>
And on Page_Load(code behind):
protected void Page_Load(object sender, EventArgs e)
{
ifrm.Attributes["src"] = "yourHtmlpageURL.html";
}
You can use it asp.net
<iframe src="http://www.google.com"></iframe>
For c# application you can use WebBrowserControl.

How to call a C# application from outside using JavaScript?

I have a C# application that uses WebForm. I am using the WebForm to display my application content (HTML / JavaScript).
My question is how do I communicate between them (API)?
Example: I like to minimize the program by using HTML buttons, etc....
If you have a web browser control on top of a normal control you could use the navigation event. E.g. make a link like:
Minimize
And in the navigation event of the browser control (I don't know how the event is actually called - just an example):
public void browser_OnNavigate(object sender, NavigateArgs e)
{
if (e.Target == "#MinimizeWindow")
// minimize and cancel event
else
// navigate to target
}
Local or Remote WebForms Application
You can use AJAX if you are trying to communicate with an external (or local) application.
Local WebForms Application
If by "application" you are actually referring to the back-end (code-behinds, etc.) of your WebForms project, then the other thing to look into are "server tags," otherwise known as "bee-stings." Here are just a few exsamples:
<% %>
<%-- --%>
<%# %>
<%= %>
Additionally, you can use event handlers for things like server-side button or anchor clicks, dropdownlist value changes, etc. You can make standard HTML controls server-side by adding the runat="server" attribute, or you can use .NET's WebControls (though they will still have to have the runat="server" attribute). Examples of these would be:
Front End
<button runat="server" onserverclick="btn_click">Click me</button>
...
or
...
<asp:Button runat="server" OnClick="btn_click">Click me</asp:Button>
Back End
protected void btn_click(object sender, EventArgs e)
{
...
}

Nested pages in ASP .NET?

I have a page called
EditProject.aspx?id=xxx
I would like to invoke it wherever I want in a modal dialog. The modal dialog is simple with bootstrap.
I would just like to know if there is a control to invoke the page somehow in a div or modal dialog.
I know about IFrame, but is there a nicer more modern way with asp .net?
Thanks
You'd be better off moving EditProject.aspx to a user control, EditPorject.ascx.
Userconrols work much the same as aspx pages, supporting the same events, but you can embed them within ASPX pages like so:
<div id="edit-project-popup">
<namespace:EditProject ID="editProject" runat="server" />
</div>
You can still access the query string parameters from the usercontrol. You can also pass values to the usercontrol by adding a property:
public partial class EditProject : UserControl
{
public int ID
{
get;
set;
}
protected void Page_Load(object sender, EventArgs e)
{
// Your Code
}
}
You can then set this property in the ASPX pages markup:
<uc:EditProject ID="editProject" runat="server" ID="xxx" />
or in the ASPX pages code behind:
editProject.ID = "xxx";
Hope this helps.
For more information on user controls see this overview on MSDN:
http://msdn.microsoft.com/en-us/library/fb3w5b53(v=vs.100).aspx

Categories

Resources