aspx

Programovacie jazyky, rady, poradňa...
flip____
Novice
Novice
Príspevky: 8
Registrovaný: 24 aug 2010, 13:52

aspx

Príspevok od používateľa flip____ »

ahojte,

mam server 2003 bezi mi na tom citrix a podobne veci ale nieje tam php.
cize c# by bolo najlepsie alebo java ......

chcem urobit .htm kde bude <form><textarea> alebo nieco podobne a po stlaceni tlacidla submit sa mi text ulozi na disk do nejakeho subotu, trebars .txt

je to aby som nemusel zakazdym chodit na server a editovat .txt ale iba by som explorerom zavolal .htm kde by som zadal text a tlacidlo by mi nahradilo text v subore novym.

napady ?
axxis
Addict
Addict
Používateľov profilový obrázok
Príspevky: 3690
Registrovaný: 29 máj 2007, 21:53
Bydlisko: Spálené mlyny
Kontaktovať používateľa:

Re: script

Príspevok od používateľa axxis »

a nebolo by lepsie spravit .aspx stranku?
pridas si do nej 2 serverove controly - text area, v tomto pripade textbox, ktory bude mat nastveny textMode na multiline (dokonca mozes pouzit aj nejaky sofistikovanejsi rich text editor) a tlacitko.
v code behind si vytvoris metodu, ktora vytiahne text z toho textboxu a ulozis na disk. to mas kodu tak na 10 riadkov

asi nejak takto

Kód: Vybrať všetko

string path ="miesto kam sa bude ukladat";
private void saveChanges(object sender, EventArgs e)
        {
            
            using (FileStream fs = new FileStream(path, FileMode.Create))
            {
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(TextBox1.Value);
                sw.Close();
            }
        }
FileMode si samozrejme nastavis aky potrebujes
flip____
Novice
Novice
Príspevky: 8
Registrovaný: 24 aug 2010, 13:52

Re: script

Príspevok od používateľa flip____ »

ano to je presne to co potrebujem lebo to chcem vlozit bud do aspx alebo do ascx stranky, tie tam su.
ale nikdy som to nepisal takze to nezvladnem sam cele , aj ked si mi poslal ten kod nizsie.
kebyze napises komplet cely kod co treba vlozit do aspx , iba treba vlozit cestu k suboru, to by bolo megasuper. [zaciatky su stale tazke] myslis ze to zvladnes ?
uz detaily by som vedel doladit , ale cely kod aby fungoval este nezvladnem.
staci mi obycajny textbox, netreba rich editor.

neviem ako to presne funguje, ale dalo by sa 5 takychto textboxov s tlacidlami dat na jednu stranku,
kazdy textbox pre iny subor ? ak nie tak aspon na jeden aby to slo.
potrebujem nechavat odkaz v 5 jazykoch, to bude vysledok.
axxis
Addict
Addict
Používateľov profilový obrázok
Príspevky: 3690
Registrovaný: 29 máj 2007, 21:53
Bydlisko: Spálené mlyny
Kontaktovať používateľa:

Re: script

Príspevok od používateľa axxis »

mas visual studio alebo visual web developer?
flip____
Novice
Novice
Príspevky: 8
Registrovaný: 24 aug 2010, 13:52

Re: script

Príspevok od používateľa flip____ »

predpokladam ze mi chces jedno z nich odporucit.

vdaka teda, stiahnem si ich a skusim ich, aspon viem v com to mam robit.
axxis
Addict
Addict
Používateľov profilový obrázok
Príspevky: 3690
Registrovaný: 29 máj 2007, 21:53
Bydlisko: Spálené mlyny
Kontaktovať používateľa:

Re: script

Príspevok od používateľa axxis »

no visual studio je mega ultimatne vyvojove prostredie, ktore Ti dokaze snad aj uvarit kavu. Web developer je jeho free obdoba, ktora Ti pomoze celkom efektivne robit .aspx stranky ( na .ascx pozor, to je nieco trochu ine ). Ak uz budes mat jedno ci druhe tak si mozes takmer cely svoj projekt naklikat a lahko mu dorobis aj kod, ktory bude bezat na serveri. viac menej len naklikanym tlacitkam priradis metody, ktore budu obsahovat to co som Ti tu ja pridal
flip____
Novice
Novice
Príspevky: 8
Registrovaný: 24 aug 2010, 13:52

Re: script

Príspevok od používateľa flip____ »

no fajn, dik za radu. mozno aj lepsia rada ako keby si mi len napisal kod toho co som chcel :)
keby som si s niecim nevedel dat rady tak aspon viem ze by si mohol vediet ty.
dik este raz

//autoeditácia príspevku (27 Aug 2010, 8:32)
http://asp-net-example.blogspot.com/sea ... %20Example

z tej stranky som vystrihol kod co je nizsie.
funguje to ked je iba jeden textbox na stranke.
ale ked to dam dvakrat funguje iba prvy ale druhy uz nie.
nejaky napad preco ? (visual studio az ked odniekial stiahnem)

<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
protected void page_Load(object sender, System.EventArgs e) {
if(!this.IsPostBack)
{
TextBoxen.Text = "ENGLISH";
}

{
TextBoxde.Text = "GERMAN";
}
}
protected void Buttonen_Click(object sender, System.EventArgs e) {
string myStringen = TextBoxen.Text.ToString();
string appPath = Request.PhysicalApplicationPath;
string filePath = appPath + "ENGLISH.txt";
Labelen.Text = "message set : ";
Labelen.Text += myStringen;
}
protected void Buttonde_Click(object sender, System.EventArgs e) {
string myStringde = TextBoxde.Text.ToString();
string appPath = Request.PhysicalApplicationPath;
string filePath = appPath + "GERMAN.txt";
Labelde.Text = "message set : ";
Labelde.Text += myStringde;
}
</script>
<head id="Head1" runat="server"><title>text</title></head> <body><center>

<table width=90% border=1 cellpadding=0 cellspacing=10><tr><td bgcolor=#567890>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBoxen" runat="server" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox>
<asp:Button ID="Buttonen" runat="server" OnClick="Buttonen_Click" Text="set the EN message" ForeColor="brown"/>
<asp:Label ID="Labelen" runat="server" Font-Size="small" ForeColor="black" Font-Italic="false"></asp:Label>

<asp:TextBox ID="TextBoxde" runat="server" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox>
<asp:Button ID="Buttonde" runat="server" OnClick="Buttonde_Click" Text="set the DE message" ForeColor="brown"/>
<asp:Label ID="Labelde" runat="server" Font-Size="small" ForeColor="black"></asp:Label>
</div>
</form></td></tr></table>
</body></html>
axxis
Addict
Addict
Používateľov profilový obrázok
Príspevky: 3690
Registrovaný: 29 máj 2007, 21:53
Bydlisko: Spálené mlyny
Kontaktovať používateľa:

Re: script

Príspevok od používateľa axxis »

flip____ napísal:no fajn, dik za radu. mozno aj lepsia rada ako keby si mi len napisal kod toho co som chcel :)
keby som si s niecim nevedel dat rady tak aspon viem ze by si mohol vediet ty.
dik este raz

//autoeditácia príspevku (27 Aug 2010, 8:32)
http://asp-net-example.blogspot.com/sea ... %20Example

z tej stranky som vystrihol kod co je nizsie.
funguje to ked je iba jeden textbox na stranke.
ale ked to dam dvakrat funguje iba prvy ale druhy uz nie.
nejaky napad preco ? (visual studio az ked odniekial stiahnem)

Kód: Vybrať všetko

<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
    protected void page_Load(object sender, System.EventArgs e) {
        if(!this.IsPostBack)
         {
            TextBoxen.Text = "ENGLISH";
            TextBoxde.Text = "GERMAN";
        }
    }
    protected void Buttonen_Click(object sender, System.EventArgs e) {
        string myStringen = TextBoxen.Text;
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "ENGLISH.txt";
        Labelen.Text = "message set : ";
        Labelen.Text += myStringen;
    }
    protected void Buttonde_Click(object sender, System.EventArgs e) {
        string myStringde = TextBoxde.Text;
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "GERMAN.txt";
        Labelde.Text = "message set : ";
        Labelde.Text += myStringde;
    }
</script>
<head id="Head1" runat="server"><title>text</title></head> <body><center>

<table width=90% border=1 cellpadding=0 cellspacing=10><tr><td bgcolor=#567890>
<form id="form1" runat="server">
<div>
        <asp:TextBox ID="TextBoxen" runat="server" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox>
        <asp:Button ID="Buttonen" runat="server" OnClick="Buttonen_Click" Text="set the EN message" ForeColor="brown"/>  
        <asp:Label ID="Labelen" runat="server" Font-Size="small" ForeColor="black" Font-Italic="false"></asp:Label>

        <asp:TextBox ID="TextBoxde" runat="server" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox>
        <asp:Button ID="Buttonde" runat="server" OnClick="Buttonde_Click" Text="set the DE message" ForeColor="brown"/>  
        <asp:Label ID="Labelde" runat="server" Font-Size="small" ForeColor="black"></asp:Label>
</div>
</form></td></tr></table>
</body></html>[/quote]
na uvod mala technicka poznamka: zdrojaky davaj vzdy do tagu Code

ku kodu samotnemu, predpokladam, ze druhy textbox sa po kazdom kliku nastavoval na GERMAN, je to preto, ze si mal jeho inicializaciu mimo podmieku if(!IsPostBack), tym padom sa pri kazdom nacitani stranky nanovo prepisal. ak pouzijes IsPostBack tak si rozozna ci je to skutocne nove nacitanie stranky, alebo len nejaky klik na button volal "refresh".
Ak by bolo viac problemov ako toto popis mi ich

inak nie som si tym uplne isty, ale mam pocit, ze cela stranka by mala byt vo vnutri <form> tagu, skus tu tabulku este nasukat dovnutra
flip____
Novice
Novice
Príspevky: 8
Registrovaný: 24 aug 2010, 13:52

Re: aspx

Príspevok od používateľa flip____ »

toto funguje.

Kód: Vybrať všetko

<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">

    protected void page_Load(object sender, System.EventArgs e) {
        if(!this.IsPostBack)
         {
            TextBoxen.Text = "Welcome";
            TextBoxde.Text = "Willkommen";
            TextBoxfr.Text = "Bienvenue";
            TextBoxes.Text = "Bienvenido";
            TextBoxru.Text = "";
            TextBoxja.Text = "";
        }
    }

    protected void Buttonen_Click(object sender, System.EventArgs e) {
        string myStringen = TextBoxen.Text.ToString();
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "en.txt";
        StreamWriter wen;
        wen = File.CreateText(filePath);
        wen.WriteLine(myStringen);
        wen.Flush();
        wen.Close();
        Labelen.Text = "";
        Labelen.Text += myStringen;
    }

    protected void Buttonde_Click(object sender, System.EventArgs e) {
        string myStringde = TextBoxde.Text.ToString();
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "de.txt";
        StreamWriter wde;
        wde = File.CreateText(filePath);
        wde.WriteLine(myStringde);
        wde.Flush();
        wde.Close();
        Labelde.Text = "";
        Labelde.Text += myStringde;
    }
    protected void Buttonfr_Click(object sender, System.EventArgs e) {
        string myStringfr = TextBoxfr.Text.ToString();
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "fr.txt";
        StreamWriter wfr;
        wfr = File.CreateText(filePath);
        wfr.WriteLine(myStringfr);
        wfr.Flush();
        wfr.Close();
        Labelfr.Text = "";
        Labelfr.Text += myStringfr;
    }

    protected void Buttones_Click(object sender, System.EventArgs e) {
        string myStringes = TextBoxes.Text.ToString();
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "es.txt";
        StreamWriter wes;
        wes = File.CreateText(filePath);
        wes.WriteLine(myStringes);
        wes.Flush();
        wes.Close();
        Labeles.Text = "";
        Labeles.Text += myStringes;
    }
</script>

<style> 
.bg { 
background-image: url(bg.jpg); 
background-repeat: no-repeat; 
} 
</style>


<head id="Head1" runat="server"><title>title</title></head><body><form id="form1" runat="server"><div>

<center>

<table width="950" border=0 cellpadding="10" cellspacing="0" class="bg">
<tr><td width="950" colspan="2" height="150"></td></tr>

<tr>
<td width="100">
<asp:Button ID="Buttonen" runat="server" width="100" height="50" OnClick="Buttonen_Click" Text="set EN" ForeColor="brown"/>
</td>
<td valign="top" width="850">
<asp:TextBox ID="TextBoxen" runat="server" width="100%" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox><br>
<asp:Label ID="Labelen" runat="server" ForeColor="blue"></asp:Label>
</td>
</tr>

<tr>
<td width="100">
<asp:Button ID="Buttonde" runat="server" width="100" height="50" OnClick="Buttonde_Click" Text="set DE" ForeColor="brown"/>
</td>
<td valign="top" width="850">
<asp:TextBox ID="TextBoxde" runat="server" width="100%" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox><br>
<asp:Label ID="Labelde" runat="server" ForeColor="blue"></asp:Label></td>
</tr>

<tr>
<td width="100">
<asp:Button ID="Buttonfr" runat="server" width="100" height="50" OnClick="Buttonfr_Click" Text="set FR" ForeColor="brown"/>
</td>
<td valign="top" width="850">
<asp:TextBox ID="TextBoxfr" runat="server" width="100%" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox><br>
<asp:Label ID="Labelfr" runat="server" ForeColor="blue"></asp:Label>
</td>
</tr>

<tr>
<td width="100">
<asp:Button ID="Buttones" runat="server" width="100" height="50" OnClick="Buttones_Click" Text="set ES" ForeColor="brown"/>
</td>
<td valign="top" width="850">
<asp:TextBox ID="TextBoxes" runat="server" width="100%" BackColor="OrangeRed" ForeColor="AliceBlue"></asp:TextBox><br>
<asp:Label ID="Labeles" runat="server" ForeColor="blue"></asp:Label></td>
</tr>
</table>
</div>
</form>
</body>
</html>


text v <TextBox> ulozi do suboru ked kliknem tlacitko.
4 rozdielne subory, kazdy pre jeden jazyk.

este chcem .aspx kod , ktory zisti ake ma user nastavene 'regional settings' a podla toho vyberie .txt subor a ukaze ho na stranke. to by nemalo byt tazke, ze ?

a dik za pomoc
axxis
Addict
Addict
Používateľov profilový obrázok
Príspevky: 3690
Registrovaný: 29 máj 2007, 21:53
Bydlisko: Spálené mlyny
Kontaktovať používateľa:

Re: aspx

Príspevok od používateľa axxis »

uff, priznam sa Ti, ze take nieco som este nerobil, ale snad pomocou kultury by sa to dalo

skus nejako zmodifikovat toto a sprav tam case podmienku podla jazyku, ktory z toho vytiahnes

Kód: Vybrať všetko

int count;
String[] userLang = Request.UserLanguages;    

for (count = 0; count < userLang.Length; count++) 
{
   Response.Write("User Language " + count +": " + userLang[count] + "<br>");
}
inak mohol by si mi vysvetlit aky ma toto zmysel?

Kód: Vybrať všetko

string myStringde = TextBoxde.Text.ToString();
        Labelde.Text = "";
        Labelde.Text += myStringde;
osobne si myslim, ze takyto kod by robil uplne to iste a dokonca aj bez toho flushu by to zrejme zvladlo

Kód: Vybrať všetko

protected void Buttonfr_Click(object sender, System.EventArgs e) {
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "fr.txt";
        using (StreamWriter wfr = File.CreateText(filePath))
        {
              wfr.WriteLine(TextBoxfr.Text);
              wfr.Flush();
        }
    }
flip____
Novice
Novice
Príspevky: 8
Registrovaný: 24 aug 2010, 13:52

Re: aspx

Príspevok od používateľa flip____ »

Kód: Vybrať všetko

string myStringde = TextBoxde.Text.ToString();
        Labelde.Text = "";
        Labelde.Text += myStringde;
to bude nejak tak ze :

Kód: Vybrať všetko

string myStringde = TextBoxde.Text.ToString();
        Labelde.Text = "new message : ";
        Labelde.Text += myStringde;

-------

Kód: Vybrať všetko

protected void Buttonfr_Click(object sender, System.EventArgs e) {
        string appPath = Request.PhysicalApplicationPath;
        string filePath = appPath + "fr.txt";
        using (StreamWriter wfr = File.CreateText(filePath))
        {
              wfr.WriteLine(TextBoxfr.Text);
              wfr.Flush();
        }
    }
toto nechce fungovat.



to language recognition budem riesit neskor, zatial mi to bezi na javascripte.

nevies nahodou ako nastavovat permissions suboru ked donho zapisujem ?

ked v adresari vytvorim .txt tak mi ho vie stranka citat ale ked pouzijem aspx co sme tu riesili a kliknem button, spravi presne to co som chcel, text v subore sa prepise na ten co je v TextArea.
ibaze od toho momentu sa zmenia aj permissions suboru a Users nemaju prava ziadne.
cize mi to nefunguje lebo z toho nevie citat.
Napísať odpoveď