|
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.
|
|
|
|
|
Simple, it submits your data. The "another page" would be the page where your form has to land after submission. Preventing the user from submitting a form via Enter key, is a bad UX, in my opinion. User would want to use keyboard for the submission process and you would be preventing him from doing so.
I have never used ASP.NET Web Forms, but I do know that even that form gets translated to HTML while rendering, so you can control that via JavaScript. Following script would suffice.
$('input[type="text"]').keydown(function (e) {
if(e.which == 13) {
return false;
}
});
This would do the trick for you, but I would suggest that you do not do so. Let user submit the form using Enter key.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thank you soo much for your kind answer.
what I actually mean is I created a search button. when I search for the result and press on ENTER, its going to default page. when I manually click on search button its showing the result.
|
|
|
|
|
We can't say from what you've posted. When you press enter in a textbox the first button of the form is clicked. So you'll need to find the first button on your form and try and work out from that what is happening. It could be clicking that button is activating js or something, we don't know.
|
|
|
|