MVC 2 <% HTML BEGIN FORM %> collides with partialview - database

I am doing a MVC 2 vb project for a company, and the following codes are used to retrieve database tables thru model.edmx. I have mutiple tabs which I've implemented separate partial views to contain the data.
View page
<% Using Html.BeginForm("BkgEntry", "BookingController")%>
<input button type="submit" />
.
.
.
<div> <% Html.RenderPartial("~/Views/Booking/pax.ascx", ViewData("pax"))%></div>
<div> <% Html.RenderPartial("~/Views/Booking/itinerary.ascx", ViewData("itinerary"))%></div>
<% End Using %>
Controller page
<HttpPost()>
Function BkgEntry(ByVal collection As FormCollection, ByVal bill As Billing, ByVal pax As Pax, ByVal Itinerary As Itinerary, ByVal id As Integer) As ActionResult
.
.
.
_db.ApplyCurrentValues(billing.EntityKey.EntitySetName, bill)
_db.ApplyCurrentValues(pa.EntityKey.EntitySetName, pax)
_db.ApplyCurrentValues(itin.EntityKey.EntitySetName, Itinerary)
_db.SaveChanges()
Return RedirectToAction("BkgEntry")
End Function
So here's the problem, when I click on "submit" button, it pops out an error refering to '_db.ApplyCurrentValues(itin.EntityKey.EntitySetName, Itinerary)
' that "itinerary" is null there it cannot be updated.
This is because "Itinerary" wasnt passed into the BkgEntry post function. Unlike Pax and Bill was able to. I have tried several methods and I derived at wondering if it is because of mutiple partial forms coliding with <%Html Begin form%>that cause the error at the view, if so, how can I solve it?

Solved. thanks anyway, it was just silly of me to include another <% HtmlBegin Form%> and <% End Using %> in the separate partial views as well, i guess the <% End Using %> in the first partial shuts down my whole <% HtmlBeign Form %> operation at the start.
Derrick

Related

Error with Nested ASP.NEt Repeaters and Database Table

I'm having some dramas with Nested Repeaters in ASP.NET using VB.
I have search through this and a few other forums but cannot work out my code problem. All of the other examples ive found have been using an XML Datasource, or using multiple tables within a dataset. My Dataset only contains 1 table with all the necessary fields.
I essentially want to create an Event Calendar... eg
-September
Event 1
Event 2
-October
Event 3
-November
Event 4
Event 5
Event 6
All of the info is stored in 1 Table in my Database.
My Code so Far...
aspx
<asp:repeater id="rptCalendar" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "Month")%>
<asp:repeater id="NestedRepeater" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "EventName")%>
<br>
</ItemTemplate>
</asp:repeater>
</ItemTemplate>
</asp:repeater>
aspx.vb
Protected Sub rptCalendar_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptCalendar.ItemDataBound
Dim dv As DataRowView = e.Item.DataItem
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim nestedrepeater As Repeater = e.Item.FindControl("NestedRepeater")
Dim drv As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
nestedrepeater.DataSource = drv.CreateChildView("EventName")
nestedrepeater.DataBind()
End If
End Sub
My Page_Load event just loads the entire table into a dataset called dsEvents and binds it. The Database looks like this.
-Events
EventID
EventName
EventDate
Month
Day
The error message im getting is
"The relation is not parented to the table to which this DataView points."
I haven't worked with Nested Repeaters before so not too sure what im doing wrong.

set datetime culture vb from database date record

I have a problem.
How can i set cultureinfo to date, when the date comes from database.
I have database, where is recorded date/time, when a request have arrived.
Now it displays it like this: 2/24/2013 5:41:12 PM and i want it to display like this 5. toukokuuta 2013. For more info about that format i want is here It's in line 68 (Finnish)
The code i already have:
<script language="VB">
Imports System
Imports System.Globalization
Imports System.Threading
Public Class FormatDate
Public Shared Sub Main()
Dim dt As DateTime = DateTime.Now
' Sets the CurrentCulture property to U.S. English.
Thread.CurrentThread.CurrentCulture = New CultureInfo("fi-FI")
' Displays dt, formatted using the ShortDatePattern
' and the CurrentThread.CurrentCulture.
Console.WriteLine(dt.ToString("d. MMMM'ta 'yyyy"))
End Sub
End Class
</script>
That code dosen't work for now.
Here is the string, which i want to combine it:
<%# DataBinder.Eval(Container.DataItem, "pvmaika") %>
(that pvmaika is database value, it means datetime)
In front of the page, where you have that
<%# Page Culture="fi-FI" Language="VB" Debug="true" %>.
Include Culture="fi-FI".
That will work!

DotNetNuke throws itself into Quirks mode without changing settings

We've never experienced this before with DNN but sites which have been running for a long time is throwing itself into Quirks mode because the FallBack Skin Doctype has changed to HTML4 (Legacy).
The only thing I am doing differently now is developing directly onto the ASCX file rather than parsing the skin like I have done in the past. I am not going anywhere near the Host Settings during this process.
Any ideas please?
Thanks
If the skin doesn't specify the DocType then DNN looks at the Host Setting for it. So, you can either change it in the host setting (preferred) or specify it in the skin. Using ASCX for defining the skin rather than HTML shouldn't make any difference.
To specify the doctype for the skin, you have two options:
1.) Create a file named, "Your Skin Name".doctype.xml. e.g. myskin.doctype.xml
In the file, put the following:
<SkinDocType>
<![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">]]>
</SkinDocType>
2.) Add the following at the top of your skin
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim skinDocType as Control = Me.Page.FindControl("skinDocType")
If Not skinDocType is Nothing
CType(skinDocType, System.Web.UI.WebControls.Literal).Text="<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
End If
End Sub
</script>

Call Skype numbers from Silverlight

I have a Silverlight application in which I display some phone numbers. I want that numbers to be displayed as links and when the user clicks on the links to be redirected to skype. (The same as on html).
This is the equivalent in html (just to understand what i need):
+11 11 111 11 11
In silverlight I tried with:
<HyperlinkButton Content="{Binding}" NavigateUri="{Binding StringFormat=callto:\{0\}}" />
but I get System.InvalidOperationException: Failed to navigate to callto:+11 11 111 11 11.
Does somebody knows a solution for this?
Can you try using Javascript to invoke that sort of anchor? If you're able to do this via Javascript, try using the Eval function to invoke the Javascript from Silverlight:
HtmlPage.Window.Eval();
This may be a little late, but if you still want to keep it in Silverlight code, then this will work:
Public Class MyHyperLink : Inherits HyperlinkButton
Sub New(ByVal uri As String)
MyBase.NavigateUri = New Uri(uri)
End Sub
Public Sub Execute()
Application.Current.Host.Content.IsFullScreen = False
MyBase.TargetName = "_blank"
MyBase.OnClick()
End Sub
End Class
And to call, add the following code::
Dim nav As New MyHyperLink(URL)
nav.Execute()

Dotnetnuke - How to write server side script in skin.ascx file

I am extremely new to dotnetnuke. I don't know which server side language can write in Dotnetnuke skin.ascx page. How to write server side script in skin.ascx file?
just use <% %> same as normal .aspx./ascx page, for example:
<%
DotNetNuke.Framework.jQuery.RequestRegistration()
%>
just use the syntax of vb or c# whatever you are using
Or alternatively use this. Also works with VB or C#
<script runat="server">
Protected Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'do something'
End Sub
</script>
You can also create a skin object which is similar to a user control see the link below for a simple example that adds hello to the login users name
http://www.datasprings.com/Resources/ArticlesInformation/DevelopingandImplementingDNNSkinObjects.aspx

Resources