|
I'm sorry but I don't quite understand the question.
Also this seems to be a separate issue, so I suggest posting a new question with relevant details.
|
|
|
|
|
|
So I have a Webforms Web Project. I have these backend master pages that I'm converting to bootstrap.css, and I thought it would be nice to support 3 languages for the rest of the backend already is set to go.
I guess this error, now on a DLL or Windows App, I would use the root namespace and then the name of the file. ???? Maybe that's what I'm missing to register the file, a namespace.
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "login.master.en-us.resources" was correctly embedded or linked into assembly "App_Web_dubrzsw3" at compile time, or that all the satellite assemblies required are loadable and fully signed.
So I made this folder call App_GlobalResources and put 3 files in it.
login.master.en-us.resx
login.master.fr-ca.resx
login.master.ex-mx.resx
Then in the master code behind page, I put this in pre-render, does the same thing page load
Imports System.Resources
Imports System.Globalization
Imports System.IO
Imports System.Reflection
Partial Class Masterpages_Admin_Login
Inherits System.Web.UI.MasterPage
Protected rm As ResourceManager
Protected ci As CultureInfo
Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
Dim m_context As HttpContext = HttpContext.Current
Dim m_localization As String = "english"
If Not (m_context.Request.QueryString("language") Is Nothing) Then
m_localization = m_context.Request.QueryString("language")
Select Case m_localization.ToLower
Case "english"
rm = New ResourceManager("login.master.en-us", Assembly.GetExecutingAssembly())
ci = New CultureInfo("en-US")
Case "french"
rm = New ResourceManager("login.master.fr-ca", Assembly.GetExecutingAssembly())
ci = New CultureInfo("fr-CA")
Case "spanish"
rm = New ResourceManager("login.master.es-mx", Assembly.GetExecutingAssembly())
ci = New CultureInfo("es-MX")
Case Else
rm = New ResourceManager("login.master.en-us", Assembly.GetExecutingAssembly())
ci = New CultureInfo("en-US")
End Select
Else
rm = New ResourceManager("login.master.en-us", Assembly.GetExecutingAssembly())
ci = New CultureInfo("en-US")
End If
End Sub
On the master page in Html, I put this in
<li class="pull-right"><a href="#top"><% rm.GetString("txtTop")%></a></li>
|
|
|
|
|
I figured it out, but the solution is long and complex
Basically, I'm going to create a new DLL that has nothing but resource strings
And call that DLL Assemby in Page Load of the Master Page.
Then use a Label Control, and populate that Label in Code Behind.
Partial Class Masterpages_Admin_Login
Inherits System.Web.UI.MasterPage
Public rm As ResourceManager
Public ci As CultureInfo
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim m_context As HttpContext = HttpContext.Current
Dim Assembly As System.Reflection.Assembly = System.Reflection.Assembly.Load("Admin_Standard")
If Not (m_context.Request.QueryString("language") Is Nothing) Then
Dim m_localization As String = m_context.Request.QueryString("language")
Select Case m_localization.ToLower
Case "english"
rm = New System.Resources.ResourceManager("Admin_Standard.labels_en", Assembly)
ci = New CultureInfo("en-US")
Case "french"
rm = New System.Resources.ResourceManager("Admin_Standard.labels_fr", Assembly)
ci = New CultureInfo("fr-CA")
Case "spanish"
rm = New System.Resources.ResourceManager("Admin_Standard.labels_es", Assembly)
ci = New CultureInfo("es-MX")
Case Else
rm = New System.Resources.ResourceManager("Admin_Standard.labels_en", Assembly)
ci = New CultureInfo("en-US")
End Select
Else
rm = New System.Resources.ResourceManager("Admin_Standard.labels_en", Assembly)
ci = New CultureInfo("en-US")
Dim m_string As String = rm.GetString("Back to top")
End If
lbl_BackToTop.Text = rm.GetString("txtTop")
End Sub
End Class
HTML
li class="pull-right"><a href="#top"><asp:Label ID="lbl_BackToTop" runat="server" Text="Back to top" /></a></li>
|
|
|
|
|
i have a one post then i wantto set for this post displaydate and display off date
from backend when i create post for ex title photos content displaystartdate and displayenddate input then save it
displaystartdate : 2015/10/2
displaystartdate : 2015/10/5
and front end when date 2015/10/2 my post automatically show up and when date is 2015/10/5 my post automatically off
there is my code who can check for me this something is wrong ~
thanks `
Protected Sub BindData(dt As Data.DataTable, SiteID As Long)
If dt.Rows.Count > 0 Then
litList.Text = ""
For i As Integer = 0 To dt.Rows.Count - 1
Dim Title As String = dt.Rows(i).Item("Title").ToString
Dim Targets As String = ""
Dim Targetsdes As String = ""
Dim ImgURL As String = ""
Dim ImgURLs As String = ""
Dim now As DateTime = DateTime.Now
Dim startTime As DateTime = dt.Rows(i).Item("DisplaySDate").ToString()
Dim endTime As DateTime = dt.Rows(i).Item("DisplayEDate").ToString()
If ((startTime <= DateTime.Now) And (endTime >= DateTime.Now)) Then
Me.Visible = True
Else
Me.Visible = False
End If
Dim URL As String = dt.Rows(i).Item("URL").ToString
If URL = "" Then
URL = "#"
Else
If dt.Rows(i).Item("Targets").ToString = True Then
Targets = " target=""_blank"" "
Targetsdes = Resources.RsAll.OpenNW
End If
End If
If dt.Rows(i).Item("Files").ToString <> "" Then
ImgURL = ViewState("Roots") & "WebTools/Thumbnail.ashx?Siteid=" & SiteID & "&MmmID=99&fd=Benner_Files&NW=696&NW=249&Pname=" & dt.Rows(i).Item("Files").ToString
End If
litList.Text &= "<li><a href=""" & URL & """ title=""" & Title & Targetsdes & """" & Targets & " ><img src=""" & ViewState("Roots") & "" & ImgURL & """ alt=""" & Title & """ /></a></li>"
litLists.Text &= "<li>"
litLists.Text &= "<div>"
If dt.Rows(i).Item("Files").ToString <> "" Then
ImgURLs = ViewState("Roots") & "WebTools/Thumbnail.ashx?Siteid=" & SiteID & "&MmmID=99&fd=Benner_Files&NW=71&NW=71&Pname=" & dt.Rows(i).Item("Filess").ToString
End If
litLists.Text &= "<a href=""#"" title=""" & Title & """><img src=""" & ViewState("Roots") & "" & ImgURLs & """ alt=""" & Title & """ title=""" & Title & """/></a>"
litLists.Text &= "<h4>" & dt.Rows(i).Item("contents").ToString & "</h4>"
litLists.Text &= "</div>"
litLists.Text &= "</li>"
Next
Else
Me.Visible = False
End If
dt.Dispose()
End Sub
|
|
|
|
|
In this kind of case the best and quickest way to find out the problem is to use the debugger. Place a breakpoint on the line
Dim startTime As DateTime = dt.Rows(i).Item("DisplaySDate").ToString()
and go through the line one-by-one. Investigate what are the values for
dt.Rows(i).Item("DisplaySDate")
and
dt.Rows(i).Item("DisplayEDate")
Could it be that that either one is empty or has a value you wouldn't expect.
Also I'd suggest using DirectCast instead of implicitly converting the string date to datetime.
|
|
|
|
|
I wanted to upload Multiple Files With ListBox in ASP.NET but there is an error at specific place....
The error on :
File.Add(FileUpload1);
It showing error on 'File.Add'
asp:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" style="z-index: 1; left: 420px; top: 315px; position: absolute; width: 285px; height: 22px" />
<asp:Button ID="btnUpload" Text="Add" runat="server" OnClick ="UploadMultipleFiles" accept ="image/gif, image/jpeg, application/exe" style="z-index: 1; left: 425px; top: 535px; position: absolute" />
<hr />
<asp:Label ID="lbl_text" runat="server" ForeColor ="Red" style="z-index: 1; left: 701px; top: 495px; position: absolute" />
<asp:ListBox ID="ListBox1" runat="server" style="z-index: 1; left: 415px; top: 371px; position: absolute; width: 280px; height: 147px; margin-left: 3px; margin-top: 0px"></asp:ListBox>
<asp:Button ID="btn_remove" runat="server" OnClick="btn_remove_Click" style="z-index: 1; left: 500px; top: 535px; position: absolute" Text="Remove" />
c#:
protected void UploadMultipleFiles(object sender, EventArgs e)
{
try
{
if (FileUpload1.HasFile)
{
if (FileUpload1.PostedFile.ContentLength > 0)
{
if (ListBox1.Items.Contains(new ListItem(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName))))
{
lbl_text.Text = "File already in the ListBox";
}
else
{
File.Add(FileUpload1);
ListBox1.Items.Add(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName));
lbl_text.Text = "Add another file or click Upload to save them all";
}
}
else
{
lbl_text.Text = "File size cannot be 0";
}
}
else
{
lbl_text.Text = "Please select a file to add";
}
}
catch (Exception ex)
{
}
}
protected void btn_remove_Click(object sender, EventArgs e)
{
if (ListBox1.Items.Count > 0)
{
if (ListBox1.SelectedIndex < 0)
{
Label1.Text = "Please select a file to remove";
}
else
{
File.RemoveAt(ListBox1.SelectedIndex);
ListBox1.Items.Remove(ListBox1.SelectedItem.Text);
lbl_text.Text = "File removed";
}
}
}
|
|
|
|
|
|
The name 'Files' does not exist in the current context
|
|
|
|
|
Thank you so much for your help.
I got the answer.
I did not declare file, that's why it shows error. now I'm done.
|
|
|
|
|
Hi,
Struggling at the moment to retrieve an image (I'm successfully putting the image into the database) and place into a webpage - I've done a lot of reading without success.
I've tried things like :-
Dim connection As New SqlConnection(access.SQLstrconn)
Dim command As New SqlCommand("Select additionaldiagram from bluediagram where ID = 24", connection)
connection.Open()
Dim pictureData As Byte() = DirectCast(command.ExecuteScalar(), Byte())
connection.Close()
Dim picture As System.Drawing.Image = Nothing
Using stream As New IO.MemoryStream(pictureData)
picture = System.Drawing.Image.FromStream(stream)
Image1 = picture
End Using
To no avail
Any help would be most appreciated
|
|
|
|
|
|
Thank you, I'll have a read
|
|
|
|
|
That's c# anyone got a vb example ?
|
|
|
|
|
|
I got the source code but there is no output coming out.
there is no any error too. can you please help me..
This is the source code I used in asp:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" style="z-index: 1; left: 420px; top: 315px; position: absolute; width: 285px; height: 22px" />
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick ="UploadMultipleFiles" accept ="image/gif, image/jpeg, file/exe" style="z-index: 1; left: 420px; top: 341px; position: absolute" />
<hr />
<asp:Label ID="lblSuccess" runat="server" ForeColor ="Red" style="z-index: 1; left: 518px; top: 344px; position: absolute" />
c#:
foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
{
string fileName = Path.GetFileName(postedFile.FileName);
postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName);
}
lblSuccess.Text = string.Format("{0} files have been uploaded successfully.", FileUpload1.PostedFiles.Count)
|
|
|
|
|
file/exe is not the MIME type for executable files. It will most likely come through as application/octet-stream , but it depends on the browser and the client OS.
NB: Uploading executable files to the web server is rather dangerous. If you haven't configured your server properly, there's a possibility that the uploaded file could be executed on your server, which would be a major security vulnerability.
How to configure uploads for IIS Web applications[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for your kind info.
This is my company requirement to do so. I will discuss about it with the authority person.
Thank You
|
|
|
|
|
We can use imageUrl to display images in treeview. My images are stored in SQL database as images. How can we display the image from database in treeview?
|
|
|
|
|
Create a Generic handler to return the image from sql.
Here is a simple example:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim id As String = context.Request.QueryString("imageID")
Dim MyImage as Byte()
context.Response.ContentType = "image/png"
context.Response.BinaryWrite(MyImage)
End Sub
And your imageurl will be GenericHandler.ashx?imageID=...
|
|
|
|
|
|
foreach (GridViewRow row in GridView_pm.Rows)
{
if (row.Cells["MachineTypeNo"].Value.ToString().Equals(txt_search.Text))
{
GridView_pm.Rows[row.Index].DefaultCellStyle.BackColor =("yellow");
}
else
{
GridView_pm.Rows[row.Index].Visible = false;
}
I don't really sure about it..can you pls help me.
|
|
|
|
|
You should write the code in row data bound event of the gridview. The following code will change the value of the corresponding row to yellow color.
protected void GridView_pm_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (!String.IsNullOrWhiteSpace(txt_search.Text))
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var rowView = e.Row.DataItem as DataRowView;
if (String.Compare(rowView["MachineTypeNo"].ToString(), txt_search.Text,true) == 0)
{
e.Row.BackColor = System.Drawing.Color.Yellow;
}
else
{
e.Row.BackColor = System.Drawing.Color.White;
}
}
}
}
Thanks & Regards
Taleeb
(trystwithdotnet.blogspot.com)
modified 29-Sep-15 4:01am.
|
|
|
|
|
Thank you for your sharing..
|
|
|
|
|
<asp:ImageButton ID="imgbtn_search" runat="server" BorderStyle="Solid" ImageUrl="~/images/search.png" style="height: 28px; position: relative; top: 11px; left: 934px; width: 30px;" OnClick="imgbtn_search_Click1"/>
<asp:TextBox ID="txt_search" placeholder="search by Machine and DD/MM/YYYY " runat="server" style="z-index: 1; left: 682px; top: 20px; position: absolute; width: 237px; bottom: 271px"></asp:TextBox>
modified 28-Sep-15 4:08am.
|
|
|
|